You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that the gunicorn signal handler for sigint is somewhat reliant on a TTY being utilized.
Note for this case: Notice how it waits the GRACEFUL_TIMEOUT duration (which FastAPI sets to 120), despite being a SIGINT.
No TTY, closing with ctrl-c -> SIGINT:
(general) [vagrant@localhost scrubbed-repo-name]$ docker run tiangolo/uvicorn-gunicorn-fastapi:python3.8
Checking for script in /app/prestart.sh
Running script /app/prestart.sh
Running inside /app/prestart.sh, you could add migrations to this file, e.g.:#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head[2020-10-29 19:18:54 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2020-10-29 19:18:54 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
[2020-10-29 19:18:54 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2020-10-29 19:18:54 +0000] [7] [INFO] Booting worker with pid: 7
[2020-10-29 19:18:55 +0000] [8] [INFO] Booting worker with pid: 8
[2020-10-29 19:18:55 +0000] [8] [INFO] Started server process [8]
[2020-10-29 19:18:55 +0000] [7] [INFO] Started server process [7]
[2020-10-29 19:18:55 +0000] [7] [INFO] Waiting for application startup.
[2020-10-29 19:18:55 +0000] [8] [INFO] Waiting for application startup.
[2020-10-29 19:18:55 +0000] [7] [INFO] Application startup complete.
[2020-10-29 19:18:55 +0000] [8] [INFO] Application startup complete.
^C[2020-10-29 19:18:56 +0000] [1] [INFO] Handling signal: int
[2020-10-29 19:20:56 +0000] [1] [INFO] Shutting down: Master
{"loglevel": "info", "workers": 2, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
Note for this case: Expected behavior
With TTY, closing with ctrl-c -> SIGINT:
(general) [vagrant@localhost scrubbed-repo-name]$ docker run -ti tiangolo/uvicorn-gunicorn-fastapi:python3.8
Checking for script in /app/prestart.sh
Running script /app/prestart.sh
Running inside /app/prestart.sh, you could add migrations to this file, e.g.:#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head{"loglevel": "info", "workers": 2, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
[2020-10-29 19:18:31 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2020-10-29 19:18:31 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
[2020-10-29 19:18:31 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2020-10-29 19:18:31 +0000] [7] [INFO] Booting worker with pid: 7
[2020-10-29 19:18:31 +0000] [8] [INFO] Booting worker with pid: 8
[2020-10-29 19:18:31 +0000] [7] [INFO] Started server process [7]
[2020-10-29 19:18:31 +0000] [8] [INFO] Started server process [8]
[2020-10-29 19:18:31 +0000] [7] [INFO] Waiting for application startup.
[2020-10-29 19:18:31 +0000] [8] [INFO] Waiting for application startup.
[2020-10-29 19:18:31 +0000] [7] [INFO] Application startup complete.
[2020-10-29 19:18:31 +0000] [8] [INFO] Application startup complete.
^C[2020-10-29 19:18:33 +0000] [1] [INFO] Handling signal: int
[2020-10-29 19:18:33 +0000] [7] [INFO] Shutting down
[2020-10-29 19:18:33 +0000] [7] [INFO] Error while closing socket [Errno 9] Bad file descriptor
[2020-10-29 19:18:33 +0000] [8] [INFO] Shutting down
[2020-10-29 19:18:33 +0000] [8] [INFO] Error while closing socket [Errno 9] Bad file descriptor
[2020-10-29 19:18:33 +0000] [7] [INFO] Waiting for application shutdown.
[2020-10-29 19:18:33 +0000] [7] [INFO] Application shutdown complete.
[2020-10-29 19:18:33 +0000] [7] [INFO] Finished server process [7]
[2020-10-29 19:18:33 +0000] [7] [INFO] Worker exiting (pid: 7)
[2020-10-29 19:18:33 +0000] [8] [INFO] Waiting for application shutdown.
[2020-10-29 19:18:33 +0000] [8] [INFO] Application shutdown complete.
[2020-10-29 19:18:33 +0000] [8] [INFO] Finished server process [8]
[2020-10-29 19:18:33 +0000] [8] [INFO] Worker exiting (pid: 8)
[2020-10-29 19:18:33 +0000] [1] [INFO] Shutting down: Master
Note for this case: Expected behavior
To show that this is only for SIGINT, here is a case where we use no TTY, but instead send {{docker stop}} -> SIGTERM:
(general) [vagrant@localhost scrubbed-repo-name]$ docker run tiangolo/uvicorn-gunicorn-fastapi:python3.8
Checking for script in /app/prestart.sh
Running script /app/prestart.sh
Running inside /app/prestart.sh, you could add migrations to this file, e.g.:#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head[2020-10-29 19:22:39 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2020-10-29 19:22:39 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
[2020-10-29 19:22:39 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2020-10-29 19:22:39 +0000] [7] [INFO] Booting worker with pid: 7
[2020-10-29 19:22:39 +0000] [8] [INFO] Booting worker with pid: 8
[2020-10-29 19:22:40 +0000] [8] [INFO] Started server process [8]
[2020-10-29 19:22:40 +0000] [7] [INFO] Started server process [7]
[2020-10-29 19:22:40 +0000] [8] [INFO] Waiting for application startup.
[2020-10-29 19:22:40 +0000] [7] [INFO] Waiting for application startup.
[2020-10-29 19:22:40 +0000] [8] [INFO] Application startup complete.
[2020-10-29 19:22:40 +0000] [7] [INFO] Application startup complete.
[2020-10-29 19:22:45 +0000] [1] [INFO] Handling signal: term
[2020-10-29 19:22:46 +0000] [8] [INFO] Shutting down
[2020-10-29 19:22:46 +0000] [8] [INFO] Error while closing socket [Errno 9] Bad file descriptor
[2020-10-29 19:22:46 +0000] [7] [INFO] Shutting down
[2020-10-29 19:22:46 +0000] [7] [INFO] Error while closing socket [Errno 9] Bad file descriptor
[2020-10-29 19:22:46 +0000] [8] [INFO] Waiting for application shutdown.
[2020-10-29 19:22:46 +0000] [8] [INFO] Application shutdown complete.
[2020-10-29 19:22:46 +0000] [8] [INFO] Finished server process [8]
{"loglevel": "info", "workers": 2, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
[2020-10-29 19:22:46 +0000] [8] [INFO] Worker exiting (pid: 8)
[2020-10-29 19:22:46 +0000] [7] [INFO] Waiting for application shutdown.
[2020-10-29 19:22:46 +0000] [7] [INFO] Application shutdown complete.
[2020-10-29 19:22:46 +0000] [7] [INFO] Finished server process [7]
[2020-10-29 19:22:46 +0000] [7] [INFO] Worker exiting (pid: 7)
{"loglevel": "info", "workers": 2, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
[2020-10-29 19:22:46 +0000] [1] [INFO] Shutting down: Master
{"loglevel": "info", "workers": 2, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
The text was updated successfully, but these errors were encountered:
It appears that the gunicorn signal handler for sigint is somewhat reliant on a TTY being utilized.
Note for this case: Notice how it waits the GRACEFUL_TIMEOUT duration (which FastAPI sets to 120), despite being a SIGINT.
No TTY, closing with ctrl-c -> SIGINT:
Note for this case: Expected behavior
With TTY, closing with ctrl-c -> SIGINT:
Note for this case: Expected behavior
To show that this is only for SIGINT, here is a case where we use no TTY, but instead send {{docker stop}} -> SIGTERM:
The text was updated successfully, but these errors were encountered: