From bbc9bba95e4bc53ed0178c1e43d33281948dec44 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Fri, 23 Jan 2026 11:03:27 +0100 Subject: [PATCH] fix: log SIGTERM as info level, not warning SIGTERM is expected during graceful shutdown and reload operations. Logging it as warning level causes unnecessary noise in error logs. SIGKILL remains at error level (suggests OOM), other signals at warning. Closes #3094 --- gunicorn/arbiter.py | 5 ++++- tests/test_arbiter.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 8e27dca4..da294283 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -551,8 +551,11 @@ class Arbiter: if sig == signal.SIGKILL: msg += " Perhaps out of memory?" self.log.error(msg) + elif sig == signal.SIGTERM: + # SIGTERM is expected during graceful shutdown + self.log.info(msg) else: - # SIGTERM/SIGQUIT are expected during shutdown + # Other signals are unexpected self.log.warning(msg) if exitcode is not None and exitcode != 0: diff --git a/tests/test_arbiter.py b/tests/test_arbiter.py index e9d03e19..ff855b46 100644 --- a/tests/test_arbiter.py +++ b/tests/test_arbiter.py @@ -407,8 +407,8 @@ class TestReapWorkers: mock_worker = mock.Mock() arbiter.WORKERS = {42: mock_worker} - # SIGTERM should be logged as warning (not error) - with mock.patch.object(arbiter.log, 'warning') as mock_log: + # SIGTERM should be logged as info (expected during graceful shutdown) + with mock.patch.object(arbiter.log, 'info') as mock_log: arbiter.reap_workers() # Should log the signal