TM312 / vat_automation

A VAT calculation application for Amazon sellers that comes with automated transaction processing, distance sale calculations, and tax record creation.
0 stars 1 forks source link

postgres is not started #2

Open mindaugasva opened 1 month ago

mindaugasva commented 1 month ago

Hi, when I start a container, api is not start and give me a error:

2024-09-11 21:43:23 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:25 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:27 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:29 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:30 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:32 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:34 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:36 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:37 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:39 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:42 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:44 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:48 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:50 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:43:57 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:43:59 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:44:12 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:44:14 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:44:35 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:44:37 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:44:39 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:44:41 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:44:43 wait-for-it.sh: waiting 2 seconds for postgres:5433
2024-09-11 21:44:45 wait-for-it.sh: timeout occurred after waiting 2 seconds for postgres:5433
2024-09-11 21:44:47 wait-for-it.sh: waiting 2 seconds for postgres:5433

postgres log:

2024-09-11 21:44:34 The files belonging to this database system will be owned by user "postgres".
2024-09-11 21:44:34 This user must also own the server process.
2024-09-11 21:44:34 
2024-09-11 21:44:34 The database cluster will be initialized with locale "en_US.utf8".
2024-09-11 21:44:34 The default database encoding has accordingly been set to "UTF8".
2024-09-11 21:44:34 The default text search configuration will be set to "english".
2024-09-11 21:44:34 
2024-09-11 21:44:34 Data page checksums are disabled.
2024-09-11 21:44:34 
2024-09-11 21:44:34 fixing permissions on existing directory /var/lib/postgresql/data ... ok
2024-09-11 21:44:34 creating subdirectories ... ok
2024-09-11 21:44:34 selecting dynamic shared memory implementation ... posix
2024-09-11 21:44:34 selecting default max_connections ... 100
2024-09-11 21:44:34 selecting default shared_buffers ... 128MB
2024-09-11 21:44:34 selecting default time zone ... UTC
2024-09-11 21:44:34 creating configuration files ... ok
2024-09-11 21:44:34 running bootstrap script ... ok
2024-09-11 21:44:36 performing post-bootstrap initialization ... ok
2024-09-11 21:44:37 syncing data to disk ... ok
2024-09-11 21:44:37 
2024-09-11 21:44:37 
2024-09-11 21:44:37 Success. You can now start the database server using:
2024-09-11 21:44:37 
2024-09-11 21:44:37     pg_ctl -D /var/lib/postgresql/data -l logfile start
2024-09-11 21:44:37 
2024-09-11 21:44:37 waiting for server to start....2024-09-11 18:44:37.581 UTC [41] LOG:  starting PostgreSQL 13.16 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
2024-09-11 21:44:37 2024-09-11 18:44:37.595 UTC [41] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-09-11 21:44:34 sh: locale: not found
2024-09-11 21:44:34 2024-09-11 18:44:34.961 UTC [35] WARNING:  no usable system locales were found
2024-09-11 21:44:37 initdb: warning: enabling "trust" authentication for local connections
2024-09-11 21:44:37 You can change this by editing pg_hba.conf or using the option -A, or
2024-09-11 21:44:37 --auth-local and --auth-host, the next time you run initdb.
2024-09-11 21:44:38 2024-09-11 18:44:38.605 UTC [1] LOG:  starting PostgreSQL 13.16 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
2024-09-11 21:44:38 2024-09-11 18:44:38.606 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-09-11 21:44:38 2024-09-11 18:44:38.608 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-09-11 21:44:38 2024-09-11 18:44:38.637 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-09-11 21:44:38 2024-09-11 18:44:38.678 UTC [56] LOG:  database system was shut down at 2024-09-11 18:44:38 UTC
2024-09-11 21:44:38 2024-09-11 18:44:38.701 UTC [1] LOG:  database system is ready to accept connections
2024-09-11 21:44:37 2024-09-11 18:44:37.646 UTC [42] LOG:  database system was shut down at 2024-09-11 18:44:36 UTC
2024-09-11 21:44:37 2024-09-11 18:44:37.675 UTC [41] LOG:  database system is ready to accept connections
2024-09-11 21:44:37  done
2024-09-11 21:44:37 server started
2024-09-11 21:44:38 CREATE DATABASE
2024-09-11 21:44:38 
2024-09-11 21:44:38 
2024-09-11 21:44:38 /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2024-09-11 21:44:38 
2024-09-11 21:44:38 waiting for server to shut down....2024-09-11 18:44:38.349 UTC [41] LOG:  received fast shutdown request
2024-09-11 21:44:38 2024-09-11 18:44:38.361 UTC [41] LOG:  aborting any active transactions
2024-09-11 21:44:38 2024-09-11 18:44:38.365 UTC [41] LOG:  background worker "logical replication launcher" (PID 48) exited with exit code 1
2024-09-11 21:44:38 2024-09-11 18:44:38.365 UTC [43] LOG:  shutting down
2024-09-11 21:44:38 2024-09-11 18:44:38.533 UTC [41] LOG:  database system is shut down
2024-09-11 21:44:38  done
2024-09-11 21:44:38 server stopped
2024-09-11 21:44:38 
2024-09-11 21:44:38 PostgreSQL init process complete; ready for start up.
2024-09-11 21:44:38 

.env:

# DOCKER IMAGE
PYTHON_VERSION=3.7-buster
POSTGRES_VERSION=13-alpine
NODE_VERSION=14.4.0
NGINX_VERSION=1.18
REDIS_VERSION=6.0.6

OWNER_NAME=jd
VERSION_NUMBER=0.8

.dev.env


FLASK_ENV=dev

SECRET_KEY_DEV=test

#DATABASE CONFIG
DATABASE_URI_DEV=postgresql+psycopg2://<username>:<password>@<host>:<port>/<database>

POSTGRES_DB=test
POSTGRES_PASSWORD=test
POSTGRES_USER=test
POSTGRES_HOST=
#POSTGRES_HOST_AUTH_METHOD=trust
...

I try to set POSTGRES_HOST=0.0.0.0 and leave blank. I get same error

I used Windows Docker Desktop.

Could you help me?

mindaugasva commented 1 month ago

I found solution.

I changed port (from 5433 to 5432) in line 272 (in docker-compose.yml): command: bash -c "./wait-for-it.sh postgres:5432 ...

and now "api" log show another error:

2024-09-12 08:37:40 wait-for-it.sh: waiting 2 seconds for postgres:5432
2024-09-12 08:37:40 wait-for-it.sh: postgres:5432 is available after 0 seconds
2024-09-12 08:37:41 [2024-09-12 05:37:41 +0000] [1] [DEBUG] Current configuration:
2024-09-12 08:37:41   config: ./gunicorn.conf.py
....
....
2024-09-12 08:38:06 [2024-09-12 05:38:06 +0000] [1] [INFO] Starting gunicorn 23.0.0
2024-09-12 08:38:06 [2024-09-12 05:38:06 +0000] [1] [DEBUG] Arbiter booted
2024-09-12 08:38:06 [2024-09-12 05:38:06 +0000] [1] [INFO] Listening at: http://0.0.0.0:5005 (1)
2024-09-12 08:38:06 [2024-09-12 05:38:06 +0000] [1] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
2024-09-12 08:38:06 [2024-09-12 05:38:06 +0000] [21] [INFO] Booting worker with pid: 21
2024-09-12 08:38:06 [2024-09-12 05:38:06 +0000] [1] [DEBUG] 1 workers
2024-09-12 08:38:07 [2024-09-12 05:38:07 +0000] [21] [ERROR] Exception in worker process
2024-09-12 08:38:07 Traceback (most recent call last):
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
2024-09-12 08:38:07     worker.init_process()
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/ggevent.py", line 146, in init_process
2024-09-12 08:38:07     super().init_process()
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 135, in init_process
2024-09-12 08:38:07     self.load_wsgi()
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
2024-09-12 08:38:07     self.wsgi = self.app.wsgi()
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 66, in wsgi
2024-09-12 08:38:07     self.callable = self.load()
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
2024-09-12 08:38:07     return self.load_wsgiapp()
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
2024-09-12 08:38:07     return util.import_app(self.app_uri)
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 370, in import_app
2024-09-12 08:38:07     mod = importlib.import_module(module)
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
2024-09-12 08:38:07     return _bootstrap._gcd_import(name[level:], package, level)
2024-09-12 08:38:07   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2024-09-12 08:38:07   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2024-09-12 08:38:07   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
2024-09-12 08:38:07   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
2024-09-12 08:38:07   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
2024-09-12 08:38:07   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2024-09-12 08:38:07   File "/home/api/wsgi.py", line 11, in <module>
2024-09-12 08:38:07     from app import (
2024-09-12 08:38:07   File "/home/api/app/__init__.py", line 13, in <module>
2024-09-12 08:38:07     from app.logs.service import LogService
2024-09-12 08:38:07   File "/home/api/app/logs/service.py", line 7, in <module>
2024-09-12 08:38:07     from app.config import basedir
2024-09-12 08:38:07   File "/home/api/app/config.py", line 87, in <module>
2024-09-12 08:38:07     class Development(Config):
2024-09-12 08:38:07   File "/home/api/app/config.py", line 102, in Development
2024-09-12 08:38:07     SESSION_REDIS = redis.from_url(os.environ.get('SESSION_REDIS_URL'))
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/redis/utils.py", line 19, in from_url
2024-09-12 08:38:07     return Redis.from_url(url, db, **kwargs)
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 696, in from_url
2024-09-12 08:38:07     connection_pool = ConnectionPool.from_url(url, db=db, **kwargs)
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 1034, in from_url
2024-09-12 08:38:07     'port': int(url.port or 6379),
2024-09-12 08:38:07   File "/usr/local/lib/python3.7/urllib/parse.py", line 180, in port
2024-09-12 08:38:07     port = int(port, 10)
2024-09-12 08:38:07 ValueError: invalid literal for int() with base 10: '<PORT>'
2024-09-12 08:38:07 [2024-09-12 05:38:07 +0000] [21] [INFO] Worker exiting (pid: 21)
2024-09-12 08:38:07 [2024-09-12 05:38:07 +0000] [1] [ERROR] Worker (pid:21) exited with code 3
2024-09-12 08:38:07 [2024-09-12 05:38:07 +0000] [1] [ERROR] Shutting down: Master
2024-09-12 08:38:07 [2024-09-12 05:38:07 +0000] [1] [ERROR] Reason: Worker failed to boot.

do you have any ideas?

2024-09-12 08:24:32 1:C 12 Sep 2024 05:24:32.335 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2024-09-12 08:24:32 1:C 12 Sep 2024 05:24:32.336 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=1, just started
2024-09-12 08:24:32 1:C 12 Sep 2024 05:24:32.336 # Configuration loaded
2024-09-12 08:24:32                 _._                                                  
2024-09-12 08:24:32            _.-``__ ''-._                                             
2024-09-12 08:24:32       _.-``    `.  `_.  ''-._           Redis 6.0.6 (00000000/0) 64 bit
2024-09-12 08:24:32   .-`` .-```.  ```\/    _.,_ ''-._                                   
2024-09-12 08:24:32  (    '      ,       .-`  | `,    )     Running in standalone mode
2024-09-12 08:24:32  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
2024-09-12 08:24:32  |    `-._   `._    /     _.-'    |     PID: 1
2024-09-12 08:24:32   `-._    `-._  `-./  _.-'    _.-'                                   
2024-09-12 08:24:32  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
2024-09-12 08:24:32  |    `-._`-._        _.-'_.-'    |           http://redis.io        
2024-09-12 08:24:32   `-._    `-._`-.__.-'_.-'    _.-'                                   
2024-09-12 08:24:32  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
2024-09-12 08:24:32  |    `-._`-._        _.-'_.-'    |                                  
2024-09-12 08:24:32   `-._    `-._`-.__.-'_.-'    _.-'                                   
2024-09-12 08:24:32       `-._    `-.__.-'    _.-'                                       
2024-09-12 08:24:32           `-._        _.-'                                           
2024-09-12 08:24:32               `-.__.-'                                               
2024-09-12 08:24:32 
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.338 # Server initialized
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.338 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.339 * Loading RDB produced by version 6.0.6
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.339 * RDB age 37 seconds
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.339 * RDB memory usage when created 0.77 Mb
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.339 * DB loaded from disk: 0.000 seconds
2024-09-12 08:24:32 1:M 12 Sep 2024 05:24:32.339 * Ready to accept connections