docker-compose graceful shutdown of uvicorn --reload
See original GitHub issueI’m trying to run uvicorn --reload in a docker-compose setup with a mounted directory of my code.
When using “ctrl+c” and other ways to end the process it ends up just haning for the graceful shutdown periode and then it gets the SIGKILL because nothings happens.
When looking at the strace
it seems to be hanging indeed:
wait4(7, 0x7ffcf1409d84, WNOHANG, NULL) = 0
getpid() = 1
write(2, "INFO: Stopping reloader process "..., 36) = 36
getsockname(3, {sa_family=AF_INET, sin_port=htons(8000), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
getpeername(3, 0x7ffcf1409f70, [16]) = -1 ENOTCONN (Transport endpoint is not connected)
close(3) = 0
wait4(7, 0x7ffcf140afe4, WNOHANG, NULL) = 0
wait4(7, 0x7ffcf140afe4, WNOHANG, NULL) = 0
getpid() = 1
wait4(7, <unfinished ...>) = ?
+++ killed by SIGKILL +++
If I disable the reloader it shutdowns down fine. I’ve uploaded a minimal sample here: https://gist.github.com/sbv-trueenergy/a9a6971778a01d1acd3c466719e690b8
Am I doing something wrong?
Issue Analytics
- State:
- Created 4 years ago
- Comments:26 (16 by maintainers)
Top Results From Across the Web
Developers - docker-compose graceful shutdown of uvicorn --reload -
I'm trying to run uvicorn --reload in a docker-compose setup with a mounted directory of my code. When using "ctrl+c" and other ways...
Read more >Docker-compose FastAPI --reload - Stack Overflow
I understand that docker itself do not reload if some changes in code. But app must be if flag --reload in command ....
Read more >tiangolo/uvicorn-gunicorn - Docker Image
It runs asynchronous Python web code in a single process. Gunicorn. You can use Gunicorn to start and manage multiple Uvicorn worker processes....
Read more >Docker Graceful Shutdown - J's Software Development Pages
Docker's compose file format allows you to specify a stop signal. This is the signal sent when the container is stopped in a...
Read more >Dockerizing FastAPI with Postgres, Uvicorn, and Traefik
Check for errors in the logs if this doesn't work via docker-compose logs -f . Postgres. To configure Postgres, we need to add...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I got a fix on this branch, fancy trying it @gnat ? https://github.com/euri10/uvicorn/tree/docker_signal
this was my inspiration after I read both excellent posts here and here
I found this read interesting https://hynek.me/articles/docker-signals/