Skip to content

Commit 1c3908d

Browse files
committed
Log worker SIGTERM exits at info level instead of error
During graceful shutdown (e.g. Heroku deploy), workers receive SIGTERM and exit with code -15. This is expected behavior, not an error. Also stops double-logging signal exits by limiting the generic exit code error log to positive (non-signal) exit codes.
1 parent cda461b commit 1c3908d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

plain/plain/server/arbiter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def reap_workers(self) -> None:
194194
if exitcode is None:
195195
continue
196196

197-
if exitcode != 0:
197+
if exitcode > 0:
198198
self.log.error("Worker (pid:%s) exited with code %s", pid, exitcode)
199199

200200
if exitcode == WORKER_BOOT_ERROR and self._halt_error is None:
@@ -212,7 +212,10 @@ def reap_workers(self) -> None:
212212
msg = f"Worker (pid:{pid}) was sent {sig_name}!"
213213
if -exitcode == signal.SIGKILL:
214214
msg += " Perhaps out of memory?"
215-
self.log.error(msg)
215+
if -exitcode == signal.SIGTERM:
216+
self.log.info(msg)
217+
else:
218+
self.log.error(msg)
216219

217220
info.heartbeat.close()
218221
info.process.join(timeout=0)

0 commit comments

Comments
 (0)