I made a django application using docker.
Currently I send hup signal to gunicorn master process to restart.
If I simply send a hup signal, the workers are likely to restart without fully completing what they were doing.
Does gunicorn support graceful restart just by sending a hup signal to the master process?
If not, how can I gracefully restart the Gunicorn?
docket exec <container name> sh -c "kill -hup $pid"
You can start gunicorn with the code:
gunicorn --pid /var/run/gunicorn.pid --bind 0.0.0.0:80 --reload myproject.asgi.application
And graceful restart with the code:
cat /var/run/gunicorn.pid | xargs kill -HUP
If you use docker, you can use the code:
docker exec -it my_container sh -c "cat /var/run/gunicorn.pid | xargs kill -HUP"