fix: drain logs + release PID/lock before watchdog os._exit, drop infographic PNG

C1: The watchdog's os._exit(1) bypassed drain_log_queue() and
remove_pid_file()/release_gateway_runtime_lock() — the three things
_exit_after_graceful_shutdown does before exiting. The watchdog's own
logger.critical('shutdown watchdog fired') was silently dropped because
it was still in the async QueueListener queue when os._exit ran. PID
file and runtime lock were stranded on next boot.

W1: Dropped 2MB infographic PNG — dead asset with zero references in
the repo. Binary blobs in git history are permanent; every clone pays
the cost forever.

Authorship: @HexLab98's commits preserved via rebase-merge.
This commit is contained in:
kshitijk4poor 2026-07-18 19:47:21 +05:30 committed by kshitij
parent e378ed0c91
commit 3ec4c9ce4d
2 changed files with 15 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 MiB

View file

@ -219,6 +219,21 @@ def arm_shutdown_watchdog(
stream.flush()
except Exception:
pass
# Mirror _exit_after_graceful_shutdown: release PID file + runtime
# lock BEFORE the log drain (locks must never be stranded), then
# drain the async log queue so the logger.critical above actually
# reaches the file before os._exit bypasses atexit. (#66892)
try:
from gateway.status import remove_pid_file, release_gateway_runtime_lock
remove_pid_file()
release_gateway_runtime_lock()
except Exception:
pass
try:
from hermes_logging import drain_log_queue
drain_log_queue(timeout=1.0)
except Exception:
pass
os._exit(exit_code)
try: