text-davinci-003 is not available at Azure since July 6, 2023, but dify Azure OpenAI key need it #273

Closed
opened 2026-02-21 17:26:36 -05:00 by yindo · 15 comments
Owner

Originally created by @zyh3826 on GitHub (Jul 17, 2023).

Dify version: Cloud | Self Host
Self Host

Steps To Reproduce

  1. cd dify/docker
  2. docker compose up -d
  3. input Azure openai key

The current behavior

image
Since text-davinci-003 is not available at Azure since July 6, 2023, I think this is a bug.
See Azure OpenAI Service legacy models
image

The expected behavior

Originally created by @zyh3826 on GitHub (Jul 17, 2023). <!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant Dify packages to make sure your issue has not already been fixed. --> Dify version: Cloud | Self Host Self Host ## Steps To Reproduce <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than Dify. Issues without reproduction steps or code examples may be immediately closed as not actionable. --> 1. cd dify/docker 2. docker compose up -d 3. input Azure openai key ## The current behavior ![image](https://github.com/langgenius/dify/assets/31238754/be1dfaf0-5a47-4048-8308-a087f1f8c5ed) Since text-davinci-003 is not available at Azure since July 6, 2023, I think this is a bug. See [Azure OpenAI Service legacy models](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/legacy-models) ![image](https://github.com/langgenius/dify/assets/31238754/f98d829f-5eeb-46b6-a2df-3c78e7dc9df6) ## The expected behavior
yindo closed this issue 2026-02-21 17:26:36 -05:00
Author
Owner

@dkphhh commented on GitHub (Jul 18, 2023):

i have the same question

@dkphhh commented on GitHub (Jul 18, 2023): i have the same question
Author
Owner

@takatost commented on GitHub (Jul 18, 2023):

fixed in #586

@takatost commented on GitHub (Jul 18, 2023): fixed in #586
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

fixed in #586

thanks, please also update the docker image in the next version

@zyh3826 commented on GitHub (Jul 18, 2023): > fixed in #586 thanks, please also update the docker image in the next version
Author
Owner

@takatost commented on GitHub (Jul 18, 2023):

fixed in #586

thanks, please also update the docker image in the next version

Yes, we'll release a new version after verifying it's error-free.

@takatost commented on GitHub (Jul 18, 2023): > > fixed in #586 > > thanks, please also update the docker image in the next version Yes, we'll release a new version after verifying it's error-free.
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

fixed in #586

thanks, please also update the docker image in the next version

Yes, we'll release a new version after verifying it's error-free.

I pull your branch and execute the following cmds:

cd api
docker build -t langgenius/dify-api:0.3.9 .

logs like this:

=> [internal] load metadata for docker.io/langgenius/base:1.0.0-bullseye-slim                                                                                                                           0.0s
 => [1/8] FROM docker.io/langgenius/base:1.0.0-bullseye-slim                                                                                                                                             0.1s
 => [internal] load build context                                                                                                                                                                        0.8s
 => => transferring context: 1.03MB                                                                                                                                                                      0.8s
 => [2/8] COPY pip.conf /root/.pip/                                                                                                                                                                      0.0s
 => [3/8] WORKDIR /app/api                                                                                                                                                                               0.0s
 => [4/8] COPY requirements.txt /app/api/requirements.txt                                                                                                                                                0.0s
 => [5/8] RUN pip install -r requirements.txt                                                                                                                                                          506.4s
 => [6/8] COPY . /app/api/                                                                                                                                                                               0.1s
 => [7/8] COPY docker/entrypoint.sh /entrypoint.sh                                                                                                                                                       0.1s
 => [8/8] RUN chmod +x /entrypoint.sh                                                                                                                                                                    0.4s
 => exporting to image                                                                                                                                                                                  15.3s
 => => exporting layers

I using docker compose up -d to start dify, at install page after I input everything, it just hangs. I check docker-api-1 and docker-worker-1 found that the logs like this:

exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory

don't know why

@zyh3826 commented on GitHub (Jul 18, 2023): > > > fixed in #586 > > > > > > thanks, please also update the docker image in the next version > > Yes, we'll release a new version after verifying it's error-free. I pull your branch and execute the following cmds: ``` cd api docker build -t langgenius/dify-api:0.3.9 . ``` logs like this: ``` => [internal] load metadata for docker.io/langgenius/base:1.0.0-bullseye-slim 0.0s => [1/8] FROM docker.io/langgenius/base:1.0.0-bullseye-slim 0.1s => [internal] load build context 0.8s => => transferring context: 1.03MB 0.8s => [2/8] COPY pip.conf /root/.pip/ 0.0s => [3/8] WORKDIR /app/api 0.0s => [4/8] COPY requirements.txt /app/api/requirements.txt 0.0s => [5/8] RUN pip install -r requirements.txt 506.4s => [6/8] COPY . /app/api/ 0.1s => [7/8] COPY docker/entrypoint.sh /entrypoint.sh 0.1s => [8/8] RUN chmod +x /entrypoint.sh 0.4s => exporting to image 15.3s => => exporting layers ``` I using `docker compose up -d` to start dify, at install page after I input everything, it just hangs. I check `docker-api-1` and `docker-worker-1` found that the logs like this: ``` exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory exec /entrypoint.sh: no such file or directory ``` don't know why
Author
Owner

@takatost commented on GitHub (Jul 18, 2023):

no such file or directory

Are you building the image on a Windows system? This might help you: https://stackoverflow.com/a/67942312

@takatost commented on GitHub (Jul 18, 2023): > no such file or directory Are you building the image on a Windows system? This might help you: https://stackoverflow.com/a/67942312
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

no such file or directory

Are you building the image on a Windows system? This might help you: https://stackoverflow.com/a/67942312

at centos7

@zyh3826 commented on GitHub (Jul 18, 2023): > > no such file or directory > > Are you building the image on a Windows system? This might help you: https://stackoverflow.com/a/67942312 at centos7
Author
Owner

@takatost commented on GitHub (Jul 18, 2023):

You can pull the latest code from the main branch again. I added the bash command before entrypoint.sh, which might avoid this issue.

@takatost commented on GitHub (Jul 18, 2023): You can pull the latest code from the main branch again. I added the bash command before entrypoint.sh, which might avoid this issue.
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

You can pull the latest code from the main branch again. I added the bash command before entrypoint.sh, which might avoid this issue.

ok, I will try

@zyh3826 commented on GitHub (Jul 18, 2023): > You can pull the latest code from the main branch again. I added the bash command before entrypoint.sh, which might avoid this issue. ok, I will try
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

@takatost I try the newest docker 0.3.10, after docker compose up -d, somthing wrong with the docker-api-1, logs like this:

Traceback (most recent call last):
  File "/usr/local/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main
    cli.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
    script.run_env()
  File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/app/api/migrations/env.py", line 113, in <module>
    run_migrations_online()
  File "/app/api/migrations/env.py", line 97, in run_migrations_online
    with connectable.connect() as connection:
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

(Background on this error at: https://sqlalche.me/e/14/e3q8)
Running migrations
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 64b051264f32, init
INFO  [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role
INFO  [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps
INFO  [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at
INFO  [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980
INFO  [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations
INFO  [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text
[2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0
[2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112)
[2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent
[2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217

this error says DB server at port 5432 may not accept TCP/IP connections, but using docker compose ps, I got this:
image
the port 5432 is listened, then I check the log of docker-db-1:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
sh: locale: not found
2023-07-19 01:19:46.780 UTC [31] WARNING:  no usable system locales were found
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start

waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:23.712 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:23.746 UTC [40] LOG:  database system was shut down at 2023-07-19 01:20:17 UTC
2023-07-19 01:20:24.019 UTC [37] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG:  received fast shutdown request
.2023-07-19 01:20:32.476 UTC [37] LOG:  aborting any active transactions
2023-07-19 01:20:32.481 UTC [37] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
2023-07-19 01:20:32.481 UTC [38] LOG:  shutting down
2023-07-19 01:20:32.486 UTC [38] LOG:  checkpoint starting: shutdown immediate
...2023-07-19 01:20:35.980 UTC [38] LOG:  checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB
2023-07-19 01:20:36.288 UTC [37] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2023-07-19 01:20:36.500 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:20:36.519 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:36.581 UTC [53] LOG:  database system was shut down at 2023-07-19 01:20:35 UTC
2023-07-19 01:20:36.833 UTC [1] LOG:  database system is ready to accept connections
2023-07-19 01:25:36.599 UTC [51] LOG:  checkpoint starting: time
2023-07-19 01:25:56.760 UTC [51] LOG:  checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB

seems like the database system is shut down due to some reasons.
then I check the docker version 0.3.9, the log of docker-db-1:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-07-19 01:33:18.446 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:33:18.462 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:33:18.737 UTC [24] LOG:  database system was shut down at 2023-07-18 08:35:15 UTC
2023-07-19 01:33:19.000 UTC [1] LOG:  database system is ready to accept connections

no error happened.
hope you can help me, thanks

@zyh3826 commented on GitHub (Jul 18, 2023): @takatost I try the newest docker 0.3.10, after `docker compose up -d`, somthing wrong with the `docker-api-1`, logs like this: ``` Traceback (most recent call last): File "/usr/local/bin/flask", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main cli.main() File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator return __ctx.invoke(f, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade _upgrade(directory, revision, sql, tag, x_arg) File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade script.run_env() File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py spec.loader.exec_module(module) # type: ignore File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/app/api/migrations/env.py", line 113, in <module> run_migrations_online() File "/app/api/migrations/env.py", line 97, in run_migrations_online with connectable.connect() as connection: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect return self._connection_cls(self, close_with_result=close_with_result) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__ else engine.raw_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection return self._wrap_pool_connect(self.pool.connect, _connection) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect Connection._handle_dbapi_exception_noconnection( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection util.raise_( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout rec = pool._do_get() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get with util.safe_reraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ compat.raise_( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get return self._create_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__ self.__connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect with util.safe_reraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ compat.raise_( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect self.dbapi_connection = connection = pool._invoke_creator(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? (Background on this error at: https://sqlalche.me/e/14/e3q8) Running migrations INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init INFO [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role INFO [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps INFO [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at INFO [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980 INFO [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations INFO [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text [2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0 [2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112) [2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent [2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217 ``` this error says DB server at port 5432 may not accept TCP/IP connections, but using `docker compose ps`, I got this: ![image](https://github.com/langgenius/dify/assets/31238754/e329ff3f-0b77-4d43-aae8-d0f186baa271) the port 5432 is listened, then I check the log of `docker-db-1`: ``` The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... UTC creating configuration files ... ok running bootstrap script ... ok sh: locale: not found 2023-07-19 01:19:46.780 UTC [31] WARNING: no usable system locales were found performing post-bootstrap initialization ... ok syncing data to disk ... ok initdb: warning: enabling "trust" authentication for local connections initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit 2023-07-19 01:20:23.712 UTC [37] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-07-19 01:20:23.746 UTC [40] LOG: database system was shut down at 2023-07-19 01:20:17 UTC 2023-07-19 01:20:24.019 UTC [37] LOG: database system is ready to accept connections done server started CREATE DATABASE /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG: received fast shutdown request .2023-07-19 01:20:32.476 UTC [37] LOG: aborting any active transactions 2023-07-19 01:20:32.481 UTC [37] LOG: background worker "logical replication launcher" (PID 43) exited with exit code 1 2023-07-19 01:20:32.481 UTC [38] LOG: shutting down 2023-07-19 01:20:32.486 UTC [38] LOG: checkpoint starting: shutdown immediate ...2023-07-19 01:20:35.980 UTC [38] LOG: checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB 2023-07-19 01:20:36.288 UTC [37] LOG: database system is shut down done server stopped PostgreSQL init process complete; ready for start up. 2023-07-19 01:20:36.500 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv6 address "::", port 5432 2023-07-19 01:20:36.519 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-07-19 01:20:36.581 UTC [53] LOG: database system was shut down at 2023-07-19 01:20:35 UTC 2023-07-19 01:20:36.833 UTC [1] LOG: database system is ready to accept connections 2023-07-19 01:25:36.599 UTC [51] LOG: checkpoint starting: time 2023-07-19 01:25:56.760 UTC [51] LOG: checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB ``` seems like the database system is shut down due to some reasons. then I check the `docker version 0.3.9`, the log of `docker-db-1`: ``` PostgreSQL Database directory appears to contain a database; Skipping initialization 2023-07-19 01:33:18.446 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv6 address "::", port 5432 2023-07-19 01:33:18.462 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-07-19 01:33:18.737 UTC [24] LOG: database system was shut down at 2023-07-18 08:35:15 UTC 2023-07-19 01:33:19.000 UTC [1] LOG: database system is ready to accept connections ``` no error happened. hope you can help me, thanks
Author
Owner

@takatost commented on GitHub (Jul 18, 2023):

@takatost I try the newest docker 0.3.10, after docker compose up -d, somthing wrong with the docker-api-1, logs like this:

Traceback (most recent call last):
  File "/usr/local/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main
    cli.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
    script.run_env()
  File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/app/api/migrations/env.py", line 113, in <module>
    run_migrations_online()
  File "/app/api/migrations/env.py", line 97, in run_migrations_online
    with connectable.connect() as connection:
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

(Background on this error at: https://sqlalche.me/e/14/e3q8)
Running migrations
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 64b051264f32, init
INFO  [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role
INFO  [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps
INFO  [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at
INFO  [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980
INFO  [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations
INFO  [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text
[2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0
[2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112)
[2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent
[2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217

this error says DB server at port 5432 may not accept TCP/IP connections, but using docker compose ps, I got this: image the port 5432 is listened, then I check the log of docker-db-1:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
sh: locale: not found
2023-07-19 01:19:46.780 UTC [31] WARNING:  no usable system locales were found
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start

waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:23.712 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:23.746 UTC [40] LOG:  database system was shut down at 2023-07-19 01:20:17 UTC
2023-07-19 01:20:24.019 UTC [37] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG:  received fast shutdown request
.2023-07-19 01:20:32.476 UTC [37] LOG:  aborting any active transactions
2023-07-19 01:20:32.481 UTC [37] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
2023-07-19 01:20:32.481 UTC [38] LOG:  shutting down
2023-07-19 01:20:32.486 UTC [38] LOG:  checkpoint starting: shutdown immediate
...2023-07-19 01:20:35.980 UTC [38] LOG:  checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB
2023-07-19 01:20:36.288 UTC [37] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2023-07-19 01:20:36.500 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:20:36.519 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:36.581 UTC [53] LOG:  database system was shut down at 2023-07-19 01:20:35 UTC
2023-07-19 01:20:36.833 UTC [1] LOG:  database system is ready to accept connections
2023-07-19 01:25:36.599 UTC [51] LOG:  checkpoint starting: time
2023-07-19 01:25:56.760 UTC [51] LOG:  checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB

seems like the database system is shut down due to some reasons. then I check the docker version 0.3.9, the log of docker-db-1:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-07-19 01:33:18.446 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:33:18.462 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:33:18.737 UTC [24] LOG:  database system was shut down at 2023-07-18 08:35:15 UTC
2023-07-19 01:33:19.000 UTC [1] LOG:  database system is ready to accept connections

no error happened. hope you can help me, thanks

This error can be ignored, it happened because the api service started before the DB finished starting up. The subsequent logs show that it has successfully started.

@takatost commented on GitHub (Jul 18, 2023): > @takatost I try the newest docker 0.3.10, after `docker compose up -d`, somthing wrong with the `docker-api-1`, logs like this: > > ``` > Traceback (most recent call last): > File "/usr/local/bin/flask", line 8, in <module> > sys.exit(main()) > File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main > cli.main() > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main > rv = self.invoke(ctx) > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke > return _process_result(sub_ctx.command.invoke(sub_ctx)) > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke > return _process_result(sub_ctx.command.invoke(sub_ctx)) > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke > return ctx.invoke(self.callback, **ctx.params) > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke > return __callback(*args, **kwargs) > File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func > return f(get_current_context(), *args, **kwargs) > File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator > return __ctx.invoke(f, *args, **kwargs) > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke > return __callback(*args, **kwargs) > File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade > _upgrade(directory, revision, sql, tag, x_arg) > File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped > f(*args, **kwargs) > File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade > command.upgrade(config, revision, sql=sql, tag=tag) > File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade > script.run_env() > File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env > util.load_python_file(self.dir, "env.py") > File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file > module = load_module_py(module_id, path) > File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py > spec.loader.exec_module(module) # type: ignore > File "<frozen importlib._bootstrap_external>", line 883, in exec_module > File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed > File "/app/api/migrations/env.py", line 113, in <module> > run_migrations_online() > File "/app/api/migrations/env.py", line 97, in run_migrations_online > with connectable.connect() as connection: > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect > return self._connection_cls(self, close_with_result=close_with_result) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__ > else engine.raw_connection() > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection > return self._wrap_pool_connect(self.pool.connect, _connection) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect > Connection._handle_dbapi_exception_noconnection( > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection > util.raise_( > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > raise exception > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect > return fn() > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect > return _ConnectionFairy._checkout(self) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout > fairy = _ConnectionRecord.checkout(pool) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout > rec = pool._do_get() > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get > with util.safe_reraise(): > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ > compat.raise_( > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > raise exception > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get > return self._create_connection() > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection > return _ConnectionRecord(self) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__ > self.__connect() > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect > with util.safe_reraise(): > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ > compat.raise_( > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > raise exception > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect > self.dbapi_connection = connection = pool._invoke_creator(self) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect > return dialect.connect(*cargs, **cparams) > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect > return self.dbapi.connect(*cargs, **cparams) > File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) > sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused > Is the server running on that host and accepting TCP/IP connections? > > (Background on this error at: https://sqlalche.me/e/14/e3q8) > Running migrations > INFO [alembic.runtime.migration] Context impl PostgresqlImpl. > INFO [alembic.runtime.migration] Will assume transactional DDL. > INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init > INFO [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role > INFO [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps > INFO [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at > INFO [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980 > INFO [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations > INFO [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text > [2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0 > [2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112) > [2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent > [2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217 > ``` > > this error says DB server at port 5432 may not accept TCP/IP connections, but using `docker compose ps`, I got this: ![image](https://user-images.githubusercontent.com/31238754/254437151-e329ff3f-0b77-4d43-aae8-d0f186baa271.png) the port 5432 is listened, then I check the log of `docker-db-1`: > > ``` > The files belonging to this database system will be owned by user "postgres". > This user must also own the server process. > > The database cluster will be initialized with locale "en_US.utf8". > The default database encoding has accordingly been set to "UTF8". > The default text search configuration will be set to "english". > > Data page checksums are disabled. > > fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok > creating subdirectories ... ok > selecting dynamic shared memory implementation ... posix > selecting default max_connections ... 100 > selecting default shared_buffers ... 128MB > selecting default time zone ... UTC > creating configuration files ... ok > running bootstrap script ... ok > sh: locale: not found > 2023-07-19 01:19:46.780 UTC [31] WARNING: no usable system locales were found > performing post-bootstrap initialization ... ok > syncing data to disk ... ok > > initdb: warning: enabling "trust" authentication for local connections > initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. > > Success. You can now start the database server using: > > pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start > > waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > 2023-07-19 01:20:23.712 UTC [37] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > 2023-07-19 01:20:23.746 UTC [40] LOG: database system was shut down at 2023-07-19 01:20:17 UTC > 2023-07-19 01:20:24.019 UTC [37] LOG: database system is ready to accept connections > done > server started > CREATE DATABASE > > > /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* > > waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG: received fast shutdown request > .2023-07-19 01:20:32.476 UTC [37] LOG: aborting any active transactions > 2023-07-19 01:20:32.481 UTC [37] LOG: background worker "logical replication launcher" (PID 43) exited with exit code 1 > 2023-07-19 01:20:32.481 UTC [38] LOG: shutting down > 2023-07-19 01:20:32.486 UTC [38] LOG: checkpoint starting: shutdown immediate > ...2023-07-19 01:20:35.980 UTC [38] LOG: checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB > 2023-07-19 01:20:36.288 UTC [37] LOG: database system is shut down > done > server stopped > > PostgreSQL init process complete; ready for start up. > > 2023-07-19 01:20:36.500 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv6 address "::", port 5432 > 2023-07-19 01:20:36.519 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > 2023-07-19 01:20:36.581 UTC [53] LOG: database system was shut down at 2023-07-19 01:20:35 UTC > 2023-07-19 01:20:36.833 UTC [1] LOG: database system is ready to accept connections > 2023-07-19 01:25:36.599 UTC [51] LOG: checkpoint starting: time > 2023-07-19 01:25:56.760 UTC [51] LOG: checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB > ``` > > seems like the database system is shut down due to some reasons. then I check the `docker version 0.3.9`, the log of `docker-db-1`: > > ``` > PostgreSQL Database directory appears to contain a database; Skipping initialization > > 2023-07-19 01:33:18.446 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv6 address "::", port 5432 > 2023-07-19 01:33:18.462 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > 2023-07-19 01:33:18.737 UTC [24] LOG: database system was shut down at 2023-07-18 08:35:15 UTC > 2023-07-19 01:33:19.000 UTC [1] LOG: database system is ready to accept connections > ``` > > no error happened. hope you can help me, thanks This error can be ignored, it happened because the api service started before the DB finished starting up. The subsequent logs show that it has successfully started.
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

@takatost I try the newest docker 0.3.10, after docker compose up -d, somthing wrong with the docker-api-1, logs like this:

Traceback (most recent call last):
  File "/usr/local/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main
    cli.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
    script.run_env()
  File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/app/api/migrations/env.py", line 113, in <module>
    run_migrations_online()
  File "/app/api/migrations/env.py", line 97, in run_migrations_online
    with connectable.connect() as connection:
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

(Background on this error at: https://sqlalche.me/e/14/e3q8)
Running migrations
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 64b051264f32, init
INFO  [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role
INFO  [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps
INFO  [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at
INFO  [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980
INFO  [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations
INFO  [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text
[2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0
[2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112)
[2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent
[2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217

this error says DB server at port 5432 may not accept TCP/IP connections, but using docker compose ps, I got this: image the port 5432 is listened, then I check the log of docker-db-1:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
sh: locale: not found
2023-07-19 01:19:46.780 UTC [31] WARNING:  no usable system locales were found
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start

waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:23.712 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:23.746 UTC [40] LOG:  database system was shut down at 2023-07-19 01:20:17 UTC
2023-07-19 01:20:24.019 UTC [37] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG:  received fast shutdown request
.2023-07-19 01:20:32.476 UTC [37] LOG:  aborting any active transactions
2023-07-19 01:20:32.481 UTC [37] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
2023-07-19 01:20:32.481 UTC [38] LOG:  shutting down
2023-07-19 01:20:32.486 UTC [38] LOG:  checkpoint starting: shutdown immediate
...2023-07-19 01:20:35.980 UTC [38] LOG:  checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB
2023-07-19 01:20:36.288 UTC [37] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2023-07-19 01:20:36.500 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:20:36.519 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:36.581 UTC [53] LOG:  database system was shut down at 2023-07-19 01:20:35 UTC
2023-07-19 01:20:36.833 UTC [1] LOG:  database system is ready to accept connections
2023-07-19 01:25:36.599 UTC [51] LOG:  checkpoint starting: time
2023-07-19 01:25:56.760 UTC [51] LOG:  checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB

seems like the database system is shut down due to some reasons. then I check the docker version 0.3.9, the log of docker-db-1:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-07-19 01:33:18.446 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:33:18.462 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:33:18.737 UTC [24] LOG:  database system was shut down at 2023-07-18 08:35:15 UTC
2023-07-19 01:33:19.000 UTC [1] LOG:  database system is ready to accept connections

no error happened. hope you can help me, thanks

This error can be ignored, it happened because the api service started before the DB finished starting up. The subsequent logs show that it has successfully started.

but at the install page, after inputs all infos, click setting, the page does nothing @takatost

@zyh3826 commented on GitHub (Jul 18, 2023): > > @takatost I try the newest docker 0.3.10, after `docker compose up -d`, somthing wrong with the `docker-api-1`, logs like this: > > ``` > > Traceback (most recent call last): > > File "/usr/local/bin/flask", line 8, in <module> > > sys.exit(main()) > > File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main > > cli.main() > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main > > rv = self.invoke(ctx) > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke > > return _process_result(sub_ctx.command.invoke(sub_ctx)) > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke > > return _process_result(sub_ctx.command.invoke(sub_ctx)) > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke > > return ctx.invoke(self.callback, **ctx.params) > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke > > return __callback(*args, **kwargs) > > File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func > > return f(get_current_context(), *args, **kwargs) > > File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator > > return __ctx.invoke(f, *args, **kwargs) > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke > > return __callback(*args, **kwargs) > > File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade > > _upgrade(directory, revision, sql, tag, x_arg) > > File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped > > f(*args, **kwargs) > > File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade > > command.upgrade(config, revision, sql=sql, tag=tag) > > File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade > > script.run_env() > > File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env > > util.load_python_file(self.dir, "env.py") > > File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file > > module = load_module_py(module_id, path) > > File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py > > spec.loader.exec_module(module) # type: ignore > > File "<frozen importlib._bootstrap_external>", line 883, in exec_module > > File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed > > File "/app/api/migrations/env.py", line 113, in <module> > > run_migrations_online() > > File "/app/api/migrations/env.py", line 97, in run_migrations_online > > with connectable.connect() as connection: > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect > > return self._connection_cls(self, close_with_result=close_with_result) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__ > > else engine.raw_connection() > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection > > return self._wrap_pool_connect(self.pool.connect, _connection) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect > > Connection._handle_dbapi_exception_noconnection( > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection > > util.raise_( > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > > raise exception > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect > > return fn() > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect > > return _ConnectionFairy._checkout(self) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout > > fairy = _ConnectionRecord.checkout(pool) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout > > rec = pool._do_get() > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get > > with util.safe_reraise(): > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ > > compat.raise_( > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > > raise exception > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get > > return self._create_connection() > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection > > return _ConnectionRecord(self) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__ > > self.__connect() > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect > > with util.safe_reraise(): > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ > > compat.raise_( > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > > raise exception > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect > > self.dbapi_connection = connection = pool._invoke_creator(self) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect > > return dialect.connect(*cargs, **cparams) > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect > > return self.dbapi.connect(*cargs, **cparams) > > File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect > > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) > > sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused > > Is the server running on that host and accepting TCP/IP connections? > > > > (Background on this error at: https://sqlalche.me/e/14/e3q8) > > Running migrations > > INFO [alembic.runtime.migration] Context impl PostgresqlImpl. > > INFO [alembic.runtime.migration] Will assume transactional DDL. > > INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init > > INFO [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role > > INFO [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps > > INFO [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at > > INFO [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980 > > INFO [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations > > INFO [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text > > [2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0 > > [2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112) > > [2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent > > [2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217 > > ``` > > > > > > > > > > > > > > > > > > > > > > > > this error says DB server at port 5432 may not accept TCP/IP connections, but using `docker compose ps`, I got this: ![image](https://user-images.githubusercontent.com/31238754/254437151-e329ff3f-0b77-4d43-aae8-d0f186baa271.png) the port 5432 is listened, then I check the log of `docker-db-1`: > > ``` > > The files belonging to this database system will be owned by user "postgres". > > This user must also own the server process. > > > > The database cluster will be initialized with locale "en_US.utf8". > > The default database encoding has accordingly been set to "UTF8". > > The default text search configuration will be set to "english". > > > > Data page checksums are disabled. > > > > fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok > > creating subdirectories ... ok > > selecting dynamic shared memory implementation ... posix > > selecting default max_connections ... 100 > > selecting default shared_buffers ... 128MB > > selecting default time zone ... UTC > > creating configuration files ... ok > > running bootstrap script ... ok > > sh: locale: not found > > 2023-07-19 01:19:46.780 UTC [31] WARNING: no usable system locales were found > > performing post-bootstrap initialization ... ok > > syncing data to disk ... ok > > > > initdb: warning: enabling "trust" authentication for local connections > > initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. > > > > Success. You can now start the database server using: > > > > pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start > > > > waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > > 2023-07-19 01:20:23.712 UTC [37] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > 2023-07-19 01:20:23.746 UTC [40] LOG: database system was shut down at 2023-07-19 01:20:17 UTC > > 2023-07-19 01:20:24.019 UTC [37] LOG: database system is ready to accept connections > > done > > server started > > CREATE DATABASE > > > > > > /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* > > > > waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG: received fast shutdown request > > .2023-07-19 01:20:32.476 UTC [37] LOG: aborting any active transactions > > 2023-07-19 01:20:32.481 UTC [37] LOG: background worker "logical replication launcher" (PID 43) exited with exit code 1 > > 2023-07-19 01:20:32.481 UTC [38] LOG: shutting down > > 2023-07-19 01:20:32.486 UTC [38] LOG: checkpoint starting: shutdown immediate > > ...2023-07-19 01:20:35.980 UTC [38] LOG: checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB > > 2023-07-19 01:20:36.288 UTC [37] LOG: database system is shut down > > done > > server stopped > > > > PostgreSQL init process complete; ready for start up. > > > > 2023-07-19 01:20:36.500 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > > 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > > 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv6 address "::", port 5432 > > 2023-07-19 01:20:36.519 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > 2023-07-19 01:20:36.581 UTC [53] LOG: database system was shut down at 2023-07-19 01:20:35 UTC > > 2023-07-19 01:20:36.833 UTC [1] LOG: database system is ready to accept connections > > 2023-07-19 01:25:36.599 UTC [51] LOG: checkpoint starting: time > > 2023-07-19 01:25:56.760 UTC [51] LOG: checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB > > ``` > > > > > > > > > > > > > > > > > > > > > > > > seems like the database system is shut down due to some reasons. then I check the `docker version 0.3.9`, the log of `docker-db-1`: > > ``` > > PostgreSQL Database directory appears to contain a database; Skipping initialization > > > > 2023-07-19 01:33:18.446 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > > 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > > 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv6 address "::", port 5432 > > 2023-07-19 01:33:18.462 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > 2023-07-19 01:33:18.737 UTC [24] LOG: database system was shut down at 2023-07-18 08:35:15 UTC > > 2023-07-19 01:33:19.000 UTC [1] LOG: database system is ready to accept connections > > ``` > > > > > > > > > > > > > > > > > > > > > > > > no error happened. hope you can help me, thanks > > This error can be ignored, it happened because the api service started before the DB finished starting up. The subsequent logs show that it has successfully started. but at the install page, after inputs all infos, click `setting`, the page does nothing @takatost
Author
Owner

@zyh3826 commented on GitHub (Jul 18, 2023):

@takatost I try the newest docker 0.3.10, after docker compose up -d, somthing wrong with the docker-api-1, logs like this:

Traceback (most recent call last):
  File "/usr/local/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main
    cli.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
    script.run_env()
  File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/app/api/migrations/env.py", line 113, in <module>
    run_migrations_online()
  File "/app/api/migrations/env.py", line 97, in run_migrations_online
    with connectable.connect() as connection:
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

(Background on this error at: https://sqlalche.me/e/14/e3q8)
Running migrations
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 64b051264f32, init
INFO  [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role
INFO  [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps
INFO  [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at
INFO  [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980
INFO  [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations
INFO  [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text
[2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0
[2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112)
[2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent
[2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217

this error says DB server at port 5432 may not accept TCP/IP connections, but using docker compose ps, I got this: image the port 5432 is listened, then I check the log of docker-db-1:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
sh: locale: not found
2023-07-19 01:19:46.780 UTC [31] WARNING:  no usable system locales were found
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start

waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:23.712 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:23.746 UTC [40] LOG:  database system was shut down at 2023-07-19 01:20:17 UTC
2023-07-19 01:20:24.019 UTC [37] LOG:  database system is ready to accept connections
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG:  received fast shutdown request
.2023-07-19 01:20:32.476 UTC [37] LOG:  aborting any active transactions
2023-07-19 01:20:32.481 UTC [37] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
2023-07-19 01:20:32.481 UTC [38] LOG:  shutting down
2023-07-19 01:20:32.486 UTC [38] LOG:  checkpoint starting: shutdown immediate
...2023-07-19 01:20:35.980 UTC [38] LOG:  checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB
2023-07-19 01:20:36.288 UTC [37] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2023-07-19 01:20:36.500 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:20:36.500 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:20:36.519 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:20:36.581 UTC [53] LOG:  database system was shut down at 2023-07-19 01:20:35 UTC
2023-07-19 01:20:36.833 UTC [1] LOG:  database system is ready to accept connections
2023-07-19 01:25:36.599 UTC [51] LOG:  checkpoint starting: time
2023-07-19 01:25:56.760 UTC [51] LOG:  checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB

seems like the database system is shut down due to some reasons. then I check the docker version 0.3.9, the log of docker-db-1:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-07-19 01:33:18.446 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-07-19 01:33:18.447 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-07-19 01:33:18.462 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-07-19 01:33:18.737 UTC [24] LOG:  database system was shut down at 2023-07-18 08:35:15 UTC
2023-07-19 01:33:19.000 UTC [1] LOG:  database system is ready to accept connections

no error happened. hope you can help me, thanks

This error can be ignored, it happened because the api service started before the DB finished starting up. The subsequent logs show that it has successfully started.

but at the install page, after inputs all infos, click setting, the page does nothing @takatost

docker compose again, everything is fine, so wierd

@zyh3826 commented on GitHub (Jul 18, 2023): > > > @takatost I try the newest docker 0.3.10, after `docker compose up -d`, somthing wrong with the `docker-api-1`, logs like this: > > > ``` > > > Traceback (most recent call last): > > > File "/usr/local/bin/flask", line 8, in <module> > > > sys.exit(main()) > > > File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main > > > cli.main() > > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1078, in main > > > rv = self.invoke(ctx) > > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke > > > return _process_result(sub_ctx.command.invoke(sub_ctx)) > > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke > > > return _process_result(sub_ctx.command.invoke(sub_ctx)) > > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke > > > return ctx.invoke(self.callback, **ctx.params) > > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke > > > return __callback(*args, **kwargs) > > > File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func > > > return f(get_current_context(), *args, **kwargs) > > > File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator > > > return __ctx.invoke(f, *args, **kwargs) > > > File "/usr/local/lib/python3.10/site-packages/click/core.py", line 783, in invoke > > > return __callback(*args, **kwargs) > > > File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade > > > _upgrade(directory, revision, sql, tag, x_arg) > > > File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 111, in wrapped > > > f(*args, **kwargs) > > > File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 200, in upgrade > > > command.upgrade(config, revision, sql=sql, tag=tag) > > > File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade > > > script.run_env() > > > File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env > > > util.load_python_file(self.dir, "env.py") > > > File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file > > > module = load_module_py(module_id, path) > > > File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py > > > spec.loader.exec_module(module) # type: ignore > > > File "<frozen importlib._bootstrap_external>", line 883, in exec_module > > > File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed > > > File "/app/api/migrations/env.py", line 113, in <module> > > > run_migrations_online() > > > File "/app/api/migrations/env.py", line 97, in run_migrations_online > > > with connectable.connect() as connection: > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect > > > return self._connection_cls(self, close_with_result=close_with_result) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__ > > > else engine.raw_connection() > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection > > > return self._wrap_pool_connect(self.pool.connect, _connection) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect > > > Connection._handle_dbapi_exception_noconnection( > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection > > > util.raise_( > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > > > raise exception > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect > > > return fn() > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect > > > return _ConnectionFairy._checkout(self) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout > > > fairy = _ConnectionRecord.checkout(pool) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout > > > rec = pool._do_get() > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get > > > with util.safe_reraise(): > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ > > > compat.raise_( > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > > > raise exception > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get > > > return self._create_connection() > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection > > > return _ConnectionRecord(self) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__ > > > self.__connect() > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect > > > with util.safe_reraise(): > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ > > > compat.raise_( > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ > > > raise exception > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect > > > self.dbapi_connection = connection = pool._invoke_creator(self) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect > > > return dialect.connect(*cargs, **cparams) > > > File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect > > > return self.dbapi.connect(*cargs, **cparams) > > > File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect > > > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) > > > sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db" (172.24.0.5), port 5432 failed: Connection refused > > > Is the server running on that host and accepting TCP/IP connections? > > > > > > (Background on this error at: https://sqlalche.me/e/14/e3q8) > > > Running migrations > > > INFO [alembic.runtime.migration] Context impl PostgresqlImpl. > > > INFO [alembic.runtime.migration] Will assume transactional DDL. > > > INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init > > > INFO [alembic.runtime.migration] Running upgrade 64b051264f32 -> 9f4e3427ea84, add created by role > > > INFO [alembic.runtime.migration] Running upgrade 9f4e3427ea84 -> a45f4dfde53b, add language to recommend apps > > > INFO [alembic.runtime.migration] Running upgrade a45f4dfde53b -> 614f77cecc48, add last active at > > > INFO [alembic.runtime.migration] Running upgrade 614f77cecc48 -> e32f6ccb87c6, e08af0a69ccefbb59fa80c778efee300bb780980 > > > INFO [alembic.runtime.migration] Running upgrade e32f6ccb87c6 -> d3d503a3471c, add is_deleted to conversations > > > INFO [alembic.runtime.migration] Running upgrade d3d503a3471c -> a5b56fb053ef, app config add speech_to_text > > > [2023-07-19 01:21:05 +0000] [112] [INFO] Starting gunicorn 20.1.0 > > > [2023-07-19 01:21:05 +0000] [112] [INFO] Listening at: http://0.0.0.0:5001 (112) > > > [2023-07-19 01:21:05 +0000] [112] [INFO] Using worker: gevent > > > [2023-07-19 01:21:05 +0000] [217] [INFO] Booting worker with pid: 217 > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > this error says DB server at port 5432 may not accept TCP/IP connections, but using `docker compose ps`, I got this: ![image](https://user-images.githubusercontent.com/31238754/254437151-e329ff3f-0b77-4d43-aae8-d0f186baa271.png) the port 5432 is listened, then I check the log of `docker-db-1`: > > > ``` > > > The files belonging to this database system will be owned by user "postgres". > > > This user must also own the server process. > > > > > > The database cluster will be initialized with locale "en_US.utf8". > > > The default database encoding has accordingly been set to "UTF8". > > > The default text search configuration will be set to "english". > > > > > > Data page checksums are disabled. > > > > > > fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok > > > creating subdirectories ... ok > > > selecting dynamic shared memory implementation ... posix > > > selecting default max_connections ... 100 > > > selecting default shared_buffers ... 128MB > > > selecting default time zone ... UTC > > > creating configuration files ... ok > > > running bootstrap script ... ok > > > sh: locale: not found > > > 2023-07-19 01:19:46.780 UTC [31] WARNING: no usable system locales were found > > > performing post-bootstrap initialization ... ok > > > syncing data to disk ... ok > > > > > > initdb: warning: enabling "trust" authentication for local connections > > > initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. > > > > > > Success. You can now start the database server using: > > > > > > pg_ctl -D /var/lib/postgresql/data/pgdata -l logfile start > > > > > > waiting for server to start....2023-07-19 01:20:23.711 UTC [37] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > > > 2023-07-19 01:20:23.712 UTC [37] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > > 2023-07-19 01:20:23.746 UTC [40] LOG: database system was shut down at 2023-07-19 01:20:17 UTC > > > 2023-07-19 01:20:24.019 UTC [37] LOG: database system is ready to accept connections > > > done > > > server started > > > CREATE DATABASE > > > > > > > > > /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* > > > > > > waiting for server to shut down...2023-07-19 01:20:32.473 UTC [37] LOG: received fast shutdown request > > > .2023-07-19 01:20:32.476 UTC [37] LOG: aborting any active transactions > > > 2023-07-19 01:20:32.481 UTC [37] LOG: background worker "logical replication launcher" (PID 43) exited with exit code 1 > > > 2023-07-19 01:20:32.481 UTC [38] LOG: shutting down > > > 2023-07-19 01:20:32.486 UTC [38] LOG: checkpoint starting: shutdown immediate > > > ...2023-07-19 01:20:35.980 UTC [38] LOG: checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=3.361 s, sync=0.005 s, total=3.499 s; sync files=250, longest=0.002 s, average=0.001 s; distance=4222 kB, estimate=4222 kB > > > 2023-07-19 01:20:36.288 UTC [37] LOG: database system is shut down > > > done > > > server stopped > > > > > > PostgreSQL init process complete; ready for start up. > > > > > > 2023-07-19 01:20:36.500 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > > > 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > > > 2023-07-19 01:20:36.500 UTC [1] LOG: listening on IPv6 address "::", port 5432 > > > 2023-07-19 01:20:36.519 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > > 2023-07-19 01:20:36.581 UTC [53] LOG: database system was shut down at 2023-07-19 01:20:35 UTC > > > 2023-07-19 01:20:36.833 UTC [1] LOG: database system is ready to accept connections > > > 2023-07-19 01:25:36.599 UTC [51] LOG: checkpoint starting: time > > > 2023-07-19 01:25:56.760 UTC [51] LOG: checkpoint complete: wrote 200 buffers (1.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=20.142 s, sync=0.002 s, total=20.162 s; sync files=69, longest=0.001 s, average=0.001 s; distance=1353 kB, estimate=1353 kB > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > seems like the database system is shut down due to some reasons. then I check the `docker version 0.3.9`, the log of `docker-db-1`: > > > ``` > > > PostgreSQL Database directory appears to contain a database; Skipping initialization > > > > > > 2023-07-19 01:33:18.446 UTC [1] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit > > > 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > > > 2023-07-19 01:33:18.447 UTC [1] LOG: listening on IPv6 address "::", port 5432 > > > 2023-07-19 01:33:18.462 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > > 2023-07-19 01:33:18.737 UTC [24] LOG: database system was shut down at 2023-07-18 08:35:15 UTC > > > 2023-07-19 01:33:19.000 UTC [1] LOG: database system is ready to accept connections > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > no error happened. hope you can help me, thanks > > > > > > This error can be ignored, it happened because the api service started before the DB finished starting up. The subsequent logs show that it has successfully started. > > but at the install page, after inputs all infos, click `setting`, the page does nothing @takatost docker compose again, everything is fine, so wierd
Author
Owner

@ycoe commented on GitHub (Jul 19, 2023):

the deployment name must the same as the model name

@ycoe commented on GitHub (Jul 19, 2023): the deployment name must the same as the model name
Author
Owner

@xiaowogit commented on GitHub (Jul 20, 2023):

fixed in #586

thanks, please also update the docker image in the next version

Yes, we'll release a new version after verifying it's error-free.

I pull your branch and execute the following cmds:

cd api
docker build -t langgenius/dify-api:0.3.9 .

logs like this:

=> [internal] load metadata for docker.io/langgenius/base:1.0.0-bullseye-slim                                                                                                                           0.0s
 => [1/8] FROM docker.io/langgenius/base:1.0.0-bullseye-slim                                                                                                                                             0.1s
 => [internal] load build context                                                                                                                                                                        0.8s
 => => transferring context: 1.03MB                                                                                                                                                                      0.8s
 => [2/8] COPY pip.conf /root/.pip/                                                                                                                                                                      0.0s
 => [3/8] WORKDIR /app/api                                                                                                                                                                               0.0s
 => [4/8] COPY requirements.txt /app/api/requirements.txt                                                                                                                                                0.0s
 => [5/8] RUN pip install -r requirements.txt                                                                                                                                                          506.4s
 => [6/8] COPY . /app/api/                                                                                                                                                                               0.1s
 => [7/8] COPY docker/entrypoint.sh /entrypoint.sh                                                                                                                                                       0.1s
 => [8/8] RUN chmod +x /entrypoint.sh                                                                                                                                                                    0.4s
 => exporting to image                                                                                                                                                                                  15.3s
 => => exporting layers

I using docker compose up -d to start dify, at install page after I input everything, it just hangs. I check docker-api-1 and docker-worker-1 found that the logs like this:

exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory
exec /entrypoint.sh: no such file or directory

don't know why

有可能是换行符问题导致文件不能正确识别,换行符换为LF,重新编译后运行

@xiaowogit commented on GitHub (Jul 20, 2023): > > > > fixed in #586 > > > > > > > > > thanks, please also update the docker image in the next version > > > > > > Yes, we'll release a new version after verifying it's error-free. > > I pull your branch and execute the following cmds: > > ``` > cd api > docker build -t langgenius/dify-api:0.3.9 . > ``` > > logs like this: > > ``` > => [internal] load metadata for docker.io/langgenius/base:1.0.0-bullseye-slim 0.0s > => [1/8] FROM docker.io/langgenius/base:1.0.0-bullseye-slim 0.1s > => [internal] load build context 0.8s > => => transferring context: 1.03MB 0.8s > => [2/8] COPY pip.conf /root/.pip/ 0.0s > => [3/8] WORKDIR /app/api 0.0s > => [4/8] COPY requirements.txt /app/api/requirements.txt 0.0s > => [5/8] RUN pip install -r requirements.txt 506.4s > => [6/8] COPY . /app/api/ 0.1s > => [7/8] COPY docker/entrypoint.sh /entrypoint.sh 0.1s > => [8/8] RUN chmod +x /entrypoint.sh 0.4s > => exporting to image 15.3s > => => exporting layers > ``` > > I using `docker compose up -d` to start dify, at install page after I input everything, it just hangs. I check `docker-api-1` and `docker-worker-1` found that the logs like this: > > ``` > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > exec /entrypoint.sh: no such file or directory > ``` > > don't know why 有可能是换行符问题导致文件不能正确识别,换行符换为LF,重新编译后运行
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#273