diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 0e7050759..de40fcb22 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -64,6 +64,8 @@ def __init__(self, app): self.master_pid = 0 self.master_name = "Master" + self.signal_warnings = [] + cwd = util.getcwd() args = sys.argv[:] @@ -204,6 +206,14 @@ def run(self): while True: self.maybe_promote_master() + warnings, self.signal_warnings = self.signal_warnings, [] + for (wpid, sig) in warnings: + self.log.warning( + "Worker with pid %s was terminated due to signal %s", + wpid, + sig, + ) + sig = self.SIG_QUEUE.pop(0) if self.SIG_QUEUE else None if sig is None: self.sleep() @@ -526,6 +536,12 @@ def reap_workers(self): if exitcode == self.APP_LOAD_ERROR: reason = "App failed to load." raise HaltServer(reason, self.APP_LOAD_ERROR) + if os.WIFSIGNALED(status): + # Log it later. Not in the SIGCHLD handler. #2564 + # https://stackoverflow.com/q/45680378 + self.signal_warnings.append( + (wpid, os.WTERMSIG(status)) + ) worker = self.WORKERS.pop(wpid, None) if not worker: