From b695b497b9b8e7351808848ab9e342219601742a Mon Sep 17 00:00:00 2001 From: Armin Berres Date: Wed, 16 Dec 2020 11:05:27 +0100 Subject: [PATCH] Log a warning when a worker was terminated due to a signal This happens for example when being OOM killed. See #2215 --- gunicorn/arbiter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 7ca2f6b7..24ec3874 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -526,6 +526,12 @@ class Arbiter(object): if exitcode == self.APP_LOAD_ERROR: reason = "App failed to load." raise HaltServer(reason, self.APP_LOAD_ERROR) + if os.WIFSIGNALED(status): + self.log.warning( + "Worker with pid %s was terminated due to signal %s", + wpid, + os.WTERMSIG(status) + ) worker = self.WORKERS.pop(wpid, None) if not worker: