Skip to content

feat(docker): container healthcheck via heartbeat - #31

Merged
raigon-pawa merged 1 commit into
mainfrom
feat/docker-healthcheck
Jul 2, 2026
Merged

feat(docker): container healthcheck via heartbeat#31
raigon-pawa merged 1 commit into
mainfrom
feat/docker-healthcheck

Conversation

@raigon-pawa

Copy link
Copy Markdown
Owner

Adds a Docker healthcheck so a wedged or disconnected bot surfaces as unhealthy in docker ps (the container already had resource limits + restart policy, but no health signal).

How it works

  • CodexBot.heartbeat — a 30s tasks.loop (started in setup_hook) writes a timestamp to HEALTH_FILE while is_ready().
  • healthcheck.py — exits non-zero if the file is missing or older than 90s (3× the interval).
  • Dockerfile HEALTHCHECK runs the probe (--interval=60s --start-period=60s --retries=3).

Notes

  • HEALTH_FILE defaults to /tmp/codex_healthy — a writable tmpfs path (the container root is read-only).
  • The loop starts in setup_hook, which the cog-load smoke test doesn't call, so no test interference.

Testing

  • Probe verified: missing file → exit 1, fresh → 0, stale → 1.
  • ruff + ruff format + pytest (21 tests) green.

🤖 Generated with Claude Code

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>
@raigon-pawa
raigon-pawa merged commit e4c2248 into main Jul 2, 2026
2 checks passed
@raigon-pawa
raigon-pawa deleted the feat/docker-healthcheck branch July 2, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant