From ee1e5c1928c71fa366dfac99c65f630e03aed8b7 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Mon, 20 Apr 2020 19:31:53 -0700 Subject: [PATCH 1/2] Log abnormal worker exit codes --- gunicorn/arbiter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 532426d21..1bab2c612 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -520,6 +520,8 @@ def reap_workers(self): # that it could not boot, we'll shut it down to avoid # infinite start/stop cycles. exitcode = status >> 8 + if exitcode != 0: + self.log.error('Worker (pid:%s) exited with code %s', wpid, exitcode) if exitcode == self.WORKER_BOOT_ERROR: reason = "Worker failed to boot." raise HaltServer(reason, self.WORKER_BOOT_ERROR) From 79fc9a3b00e43dd152894d38ba81ae0776461127 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Mon, 20 Apr 2020 19:32:12 -0700 Subject: [PATCH 2/2] Log abnormal arbiter shutdown at error level --- gunicorn/arbiter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 1bab2c612..f827572d9 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -340,9 +340,12 @@ def wakeup(self): def halt(self, reason=None, exit_status=0): """ halt arbiter """ self.stop() - self.log.info("Shutting down: %s", self.master_name) + + log_func = self.log.info if exit_status == 0 else self.log.error + log_func("Shutting down: %s", self.master_name) if reason is not None: - self.log.info("Reason: %s", reason) + log_func("Reason: %s", reason) + if self.pidfile is not None: self.pidfile.unlink() self.cfg.on_exit(self)