-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Retain argv + fds on re-exec, fix USR2 under systemd by notifying new PID #3285
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
base: master
Are you sure you want to change the base?
Conversation
|
what , does thsi patch exactly in simple word and how do you guarantee the compatibility with current systems not running systemd? |
|
This PR is a superset of #3419 and I will rebase and fix it once that one is merged.
Use fd numbers and argv as-is, and keep systemd informed about status changes.
The status changes are effectively no-op outside of systemd, so only 3 changes remain to be judged in that regard:
I deliberately did not guard these 3 changes behind a |
this prevents changing fd numbers for * systemd socket inheritance * master re-exec * startup with --bind=fd://3
This PR stops mangling sys.argv and socket fd numbers on re-exec, thus permitting much improved integration with systemd.
-mswitch is the recommended procedure, so that should workNew feature: send timestamp to properly synchronize reload cycles using
Type=notify-reload(systemd>= v253)Fixes: module invocation breaks USR2 upgrading, as modified argv results in modified path #3281
Fixes: more status to systemd #1948
Fixes: Bind to unix socket *and* IP: gunicorn only binds to socket. #2104
Fixes: Compatibility of systemd with zero downtime reloads with SIGUSR2 #2856
systemctl -s USR2 gunicorn.servicenow automatically issues graceful quitsystemctl reload gunicorn.serviceandsystemctl restart gunicorn.serviceunchanged in .service exampleImproves systemd-specific case of: Error instead of warning in logs when sending SIGTERM since v21 #3050
Improves sock fd leak pointed out in: fd leak in thread worker causing periodic outages #3339
Follow-Up plans not included here:
systemd[1]: gunicorn.service: Supervising process 1337 which is not our child. We'll most likely not notice when it exits.warning, at all< 3.10and Python>= 3.10BARRIER=1so reloading/re-execing in quick success is reliable as wellEXTEND_TIMEOUT_USEC=so automatic timeouts are reliable as well