The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a planned stop stays planned when the watcher beats the CLI's SIGTERM
teknium1332159e79f35
diff --git a/gateway/run.py b/gateway/run.pyindex 7d1f33e6170..8ba08d15c52 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -5264,6 +5264,8 @@ def _start_gateway_make_restart_signal_handler(runner):def _start_gateway_make_shutdown_signal_handler(runner, _signal_initiated_shutdown: list):"""Build the SIGINT/SIGTERM handler; ``_signal_initiated_shutdown[0]`` records an unplanned signal."""+ planned_stop_seen = [False]+def shutdown_signal_handler(received_signal=None):# Planned --replace takeover (sibling marked this PID): exit 0 so systemd won't revive us.def _takeover() -> bool:@@ -5283,6 +5285,12 @@ def _start_gateway_make_shutdown_signal_handler(runner, _signal_initiated_shutdoplanned_takeover = bool(_best_effort(_takeover, "Takeover marker check failed: %s"))planned_stop = received_signal == signal.SIGINT or (not planned_takeover and bool(_best_effort(_planned_stop, "Planned stop marker check failed: %s")))+ # `hermes gateway stop` writes the marker, THEN signals: the planned-stop watcher can consume+ # the marker in between, and the CLI's own SIGTERM must not then read as an external kill.+ if planned_stop:+ planned_stop_seen[0] = True+ elif planned_stop_seen[0] and not planned_takeover:+ planned_stop = True_shutdown_ctx = _best_effort(_snapshot, "snapshot_shutdown_context failed: %s")sig_name = _shutdown_ctx["signal"] if _shutdown_ctx else None