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

Retain argv + fds on re-exec, fix USR2 under systemd by notifying new PID #3285

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

pajod
Copy link
Contributor

@pajod pajod commented Aug 23, 2024

This PR stops mangling sys.argv and socket fd numbers on re-exec, thus permitting much improved integration with systemd.

  • While not meant to break anything before that, this patch is only effective in cPython >= 3.10.
    • Python docs explicitly say that relaunching with -m switch is the recommended procedure, so that should work
diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py
-        args = sys.argv[:]
-        args.insert(0, sys.executable)
+        if sys.version_info < (3, 10):
+            args = sys.argv[:]
+            args.insert(0, sys.executable)
+        else:
+            args = sys.orig_argv[:]

@pajod pajod changed the title Use original arguments on arbiter re-exec, and tell systemd so exiting old master does not terminate service Retain argv + fds on re-exec, notify about MAINPID to fix USR2 under systemd Apr 10, 2025
@pajod pajod changed the title Retain argv + fds on re-exec, notify about MAINPID to fix USR2 under systemd Retain argv + fds on re-exec, fix USR2 under systemd by notifying new PID Apr 10, 2025
@pajod pajod marked this pull request as ready for review April 10, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant