feat(docker): container healthcheck via heartbeat - #31
Merged
Conversation
CodexBot.heartbeat (a 30s tasks.loop started in setup_hook) writes a timestamp to HEALTH_FILE while connected. healthcheck.py checks the file's age; the Dockerfile HEALTHCHECK runs it, so `docker ps` shows `unhealthy` if the event loop wedges or the bot never connects. The loop starts in setup_hook (not cog_load), so the cog-load smoke test doesn't trigger it. HEALTH_FILE defaults to a tmpfs path (root fs is read-only). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Adds a Docker healthcheck so a wedged or disconnected bot surfaces as
unhealthyindocker ps(the container already had resource limits + restart policy, but no health signal).How it works
CodexBot.heartbeat— a 30stasks.loop(started insetup_hook) writes a timestamp toHEALTH_FILEwhileis_ready().healthcheck.py— exits non-zero if the file is missing or older than 90s (3× the interval).HEALTHCHECKruns the probe (--interval=60s --start-period=60s --retries=3).Notes
HEALTH_FILEdefaults to/tmp/codex_healthy— a writable tmpfs path (the container root is read-only).setup_hook, which the cog-load smoke test doesn't call, so no test interference.Testing
ruff+ruff format+pytest(21 tests) green.🤖 Generated with Claude Code