question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docker-compose graceful shutdown of uvicorn --reload

See original GitHub issue

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 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:closed
  • Created 4 years ago
  • Comments:26 (16 by maintainers)

github_iconTop GitHub Comments

4reactions
euri10commented, Dec 11, 2019

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

2reactions
euri10commented, Aug 27, 2019

I found this read interesting https://hynek.me/articles/docker-signals/

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found