Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful shutdown nginx and uwsgi #30

Merged
merged 2 commits into from
Jun 22, 2018
Merged

Graceful shutdown nginx and uwsgi #30

merged 2 commits into from
Jun 22, 2018

Conversation

desaintmartin
Copy link
Contributor

@desaintmartin desaintmartin commented Jun 13, 2018

Currently, when the container is stopped, supervisor sends a SIGTERM signal to both nginx and uwsgi.

By default, on nginx, it causes a fast shutdown (not honoring open requests), and on uwsgi it causes a brutal kill of all workers.

This PR makes supervisor send a SIGQUIT to nginx (graceful stop), and add a built-in handler in uwsgi to gracefully stop workers.

Results: no more errors when doing a kubernetes rolling-release for servers with frequent long-requests.

Caveats: you need "master" mode in uwsgi to be enabled (true by default).

@tiangolo tiangolo merged commit 85196f3 into tiangolo:master Jun 22, 2018
@tiangolo
Copy link
Owner

Great job @desaintmartin !

And great research, the hook-master-start = unix_signal:15 gracefully_kill_them_all was hard to find, quite "undocumented" in uWSGI.

Thanks a lot! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants