File tree 3 files changed +18
-3
lines changed
3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -1100,6 +1100,10 @@ A filename to use for the PID file.
1100
1100
1101
1101
If not set, no PID file will be written.
1102
1102
1103
+ .. note ::
1104
+ During master re-exec, a ``.2 `` suffix is added to
1105
+ this path to store the PID of the newly launched master.
1106
+
1103
1107
.. _worker-tmp-dir :
1104
1108
1105
1109
``worker_tmp_dir ``
Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ def __init__(self, app):
59
59
self .pidfile = None
60
60
self .systemd = False
61
61
self .worker_age = 0
62
+ # old master has != 0 until new master is dead or promoted
62
63
self .reexec_pid = 0
64
+ # new master has != 0 until old master is dead (until promotion)
63
65
self .master_pid = 0
64
66
self .master_name = "Master"
65
67
@@ -411,8 +413,10 @@ def reexec(self):
411
413
master_pid = os .getpid ()
412
414
self .reexec_pid = os .fork ()
413
415
if self .reexec_pid != 0 :
416
+ # old master
414
417
return
415
418
419
+ # new master
416
420
self .cfg .pre_exec (self )
417
421
418
422
environ = self .cfg .env_orig .copy ()
@@ -517,7 +521,13 @@ def reap_workers(self):
517
521
break
518
522
if self .reexec_pid == wpid :
519
523
self .reexec_pid = 0
524
+ self .log .info ("Master exited before promotion." )
525
+ continue
520
526
else :
527
+ worker = self .WORKERS .pop (wpid , None )
528
+ if not worker :
529
+ self .log .debug ("Non-worker subprocess (pid:%s) exited" , wpid )
530
+ continue
521
531
# A worker was terminated. If the termination reason was
522
532
# that it could not boot, we'll shut it down to avoid
523
533
# infinite start/stop cycles.
@@ -552,9 +562,6 @@ def reap_workers(self):
552
562
msg += " Perhaps out of memory?"
553
563
self .log .error (msg )
554
564
555
- worker = self .WORKERS .pop (wpid , None )
556
- if not worker :
557
- continue
558
565
worker .tmp .close ()
559
566
self .cfg .child_exit (self , worker )
560
567
except OSError as e :
Original file line number Diff line number Diff line change @@ -1123,6 +1123,10 @@ class Pidfile(Setting):
1123
1123
A filename to use for the PID file.
1124
1124
1125
1125
If not set, no PID file will be written.
1126
+
1127
+ .. note::
1128
+ During master re-exec, a ``.2`` suffix is added to
1129
+ this path to store the PID of the newly launched master.
1126
1130
"""
1127
1131
1128
1132
You can’t perform that action at this time.
0 commit comments