Skip to content

Commit

Permalink
not all children die equally
Browse files Browse the repository at this point in the history
  • Loading branch information
pajod committed Sep 12, 2024
1 parent 7475a75 commit 0d941d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/source/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,10 @@ A filename to use for the PID file.

If not set, no PID file will be written.

.. note::
During master re-exec, a ``.2`` suffix is added to
this path to store the PID of the newly launched master.

.. _worker-tmp-dir:

``worker_tmp_dir``
Expand Down
6 changes: 6 additions & 0 deletions gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def __init__(self, app):
self.pidfile = None
self.systemd = False
self.worker_age = 0
# old master has != 0 until new master is dead or promoted
self.reexec_pid = 0
# new master has != 0 until old master is dead (until promotion)
self.master_pid = 0
self.master_name = "Master"

Expand Down Expand Up @@ -411,8 +413,10 @@ def reexec(self):
master_pid = os.getpid()
self.reexec_pid = os.fork()
if self.reexec_pid != 0:
# old master
return

# new master
self.cfg.pre_exec(self)

environ = self.cfg.env_orig.copy()
Expand Down Expand Up @@ -515,6 +519,8 @@ def reap_workers(self):
wpid, status = os.waitpid(-1, os.WNOHANG)
if not wpid:
break
if self.reexec_pid == wpid:
self.log.info("Master exited before promotion.")
if self.reexec_pid == wpid:
self.reexec_pid = 0
else:
Expand Down
4 changes: 4 additions & 0 deletions gunicorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,10 @@ class Pidfile(Setting):
A filename to use for the PID file.
If not set, no PID file will be written.
.. note::
During master re-exec, a ``.2`` suffix is added to
this path to store the PID of the newly launched master.
"""


Expand Down

0 comments on commit 0d941d8

Please sign in to comment.