\ Relaunch the master and workers.
(self)
| 467 | self.reap_dirty_arbiter() |
| 468 | |
| 469 | def reexec(self): |
| 470 | """\ |
| 471 | Relaunch the master and workers. |
| 472 | """ |
| 473 | if self.reexec_pid != 0: |
| 474 | self.log.warning("USR2 signal ignored. Child exists.") |
| 475 | return |
| 476 | |
| 477 | if self.master_pid != 0: |
| 478 | self.log.warning("USR2 signal ignored. Parent exists.") |
| 479 | return |
| 480 | |
| 481 | master_pid = os.getpid() |
| 482 | self.reexec_pid = os.fork() |
| 483 | if self.reexec_pid != 0: |
| 484 | return |
| 485 | |
| 486 | self.cfg.pre_exec(self) |
| 487 | |
| 488 | environ = self.cfg.env_orig.copy() |
| 489 | environ['GUNICORN_PID'] = str(master_pid) |
| 490 | |
| 491 | if self.systemd: |
| 492 | environ['LISTEN_PID'] = str(os.getpid()) |
| 493 | environ['LISTEN_FDS'] = str(len(self.LISTENERS)) |
| 494 | else: |
| 495 | environ['GUNICORN_FD'] = ','.join( |
| 496 | str(lnr.fileno()) for lnr in self.LISTENERS) |
| 497 | |
| 498 | os.chdir(self.START_CTX['cwd']) |
| 499 | |
| 500 | # exec the process using the original environment |
| 501 | os.execvpe(self.START_CTX[0], self.START_CTX['args'], environ) |
| 502 | |
| 503 | def reload(self): |
| 504 | # Track reload stats |