Repository navigation
Arm SIGTERM before a launcher-refused bot advertises health - #1200
Merged
Merged
Conversation
jatmn
marked this pull request as ready for review
December 6, 2026 00:19
There was a problem hiding this comment.
✅ No new issues found.
Approach
The bot registers its Unix SIGTERM handler before binding health or logging a launcher refusal, closing the window in which SIGTERM could kill an already observable child.
Reviewed changes
I traced the launcher refusal path, the shared shutdown listener, and the regression coverage.
- Bot startup. A refused bot can answer health probes and idle without opening the database or writing a readiness marker.
- Shared runtime. The Unix SIGTERM stream subscribes before the receiver task runs, and the existing process-wide latch retains the shutdown request for later waiters. Tokio signal registration
- Regression coverage. The new test sends real SIGTERM before the receiver task can run. The existing launcher test checks HTTP 200 from
/health, HTTP 503 from/ready, and exit code 0 after SIGTERM.
cargo test --locked -p jmodguard-runtime and cargo fmt --all -- --check passed locally. The new SIGTERM test also passed 20 additional runs. The bot CI job was still running at review time. Bot CI job
gpt-6.2-sol | 𝕏
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.

Part of #666. A bot held by an unsupported launcher could advertise its refusal, return HTTP 200 from
/healthand HTTP 503 from/ready, then die from SIGTERM instead of exiting cleanly. CI observed the failure and a pass on the identical checkout. Failure · RerunThe bot now arms the shared shutdown listener before it publishes health or refusal in that startup path. On Unix the caller registers the SIGTERM stream synchronously. The receiving task uses the existing process-wide latch, so a signal delivered before the task first runs reaches later waiters.
Verification
Summary by Sourcery
Ensure launcher-refused bots are ready to handle SIGTERM before advertising health or refusal.
Bug Fixes:
Enhancements:
Tests: