Repository navigation
ops/engine-exec.sh: hold a unit on the engine's death, not on a slow /health - #179
Open
AgentSparko wants to merge 1 commit into
Open
AgentSparko wants to merge 1 commit into
AgentSparko wants to merge 1 commit into
Conversation
…/health The unit's ExecStart must outlive start.sh (which backgrounds the engine and returns) so the unit's cgroup owns the engine; but a hold loop that exits on the first `curl -m 10 /health` miss mistakes a stalled engine for a dead one. A long disk-tier save or a GPU sync parks every Python thread past the timeout while the kernel still accepts connections — a keep-alive client finishes its request while a fresh probe hears nothing — and the exit then took a serving engine down with its cgroup (four times in one morning, 2026-11-21). The reference supervisor ships in ops/, not installed: a box's unit is its own file, like ops/qwen38-engine.service. It passes the engine-slot guard's exit 75 through when the guard is present, finds the engine by pidfile with the port's owner as fallback, and releases the unit only when QSE_HOLD_FAILS (6) probes in a row fail AND the pid is dead AND nothing listens on the port: a dead engine fails all three at once, a busy one fails none of them for long. tests/test_engine_exec_hold.py drives a stub engine through the cases (a dead engine lets go, a silent-but-live one holds, a recovered probe resets the count, a dead pid with a claimed port holds, install.sh does not copy the script): 6/6.
AgentSparko
force-pushed
the
engine-exec-hold-on-death
branch
from
November 21, 2026 10:25
39cefe4 to
7fe894b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
Type=simplesystemd unit that supervises the engine needs a main process that outlivesstart.sh's return; this PR ships the reference one inops/engine-exec.sh— and, its real point, the hold it runs survives a stalled-but-live engine instead of bouncing it.The failure mode it removes: a
while curl -sf -m 10 /healthloop that exits on the first miss treats silence as death. A live engine can be silent far past 10 s — a long disk-tier save or a GPU sync holds every Python thread while the kernel still accepts connections, so a client on keep-alive finishes its request while a fresh probe hears nothing. The supervisor's exit then took the engine down with the unit's cgroup mid-request: a serving engine was bounced four times in one morning, each exit followed by a clean drain and a minutes-long reload.What the hold requires now, all three before the unit lets go:
QSE_HOLD_FAILS(default 6) consecutive failed probes — one slow probe is logged and held, a healthy answer resets the countkill -0, with a port-owner fallback when the pidfile never appearedA dead engine fails all three at once (~35 s at the defaults); a busy one fails none of them for long.
Also in the diff:
start.shis invoked throughbashlike every sibling call (OPS-167), the pidfile gets 120 s with a port-owner fallback so the script never exits while the engine lives, and an optionalops/engine-slot.sh(claim|release, not shipped) lets a box share one accelerator between engines.install.shdoes not copy it — a box's unit is its own file, likeops/qwen38-engine.service— and the changelog entry says why.Test plan
tests/test_engine_exec_hold.py— new; drives a stub engine (pidfile of asleep, control-filecurl/sson a stub PATH) through the four cases: silent-but-alive is held past the old single-miss line, a recovered probe restarts the count at 1, a dead pid with a claimed port still holds (respawn), and a truly dead engine lets the unit go. 6/6 pass.tests/test_no_exec_bit.py— 5/5 pass (the direct-call tokenizer is clean for the new script).bash -nclean.Note on the local suite:
tests/test_install_ops_copy.pycannot run its fixture on a host whose global pre-commit hook pins a specific author identity — the fixture commits ast <t@example.com>and the hook refuses. Environmental, unrelated to this diff.