feat(healthcheck): add runtime /health endpoint with DB/Discord readiness and heartbeat probes#59
feat(healthcheck): add runtime /health endpoint with DB/Discord readiness and heartbeat probes#59Copilot wants to merge 21 commits into
Conversation
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/c97c5f48-bf46-4233-9bd6-a5b2e3b9fe04 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/c97c5f48-bf46-4233-9bd6-a5b2e3b9fe04 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
|
@copilot astral.sh is now excluded from the firewall, if you need to make further changes based on that |
ToothyDev
left a comment
There was a problem hiding this comment.
Additionally, if possible, check for any shard heartbeats being blocked in order to help catch stalls of any kind (e.g. by blocking code)
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/9e556274-2b93-48f7-9e72-478e586eae74 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/9e556274-2b93-48f7-9e72-478e586eae74 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Added a heartbeat health probe to the healthcheck response ( |
|
@copilot Change pull request title according to semantic PR titles |
Proposed semantic title: |
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/03a42855-7f38-4d7c-a520-0218b63e29f2 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/d12d56d3-da0d-4c5d-b45a-8580f7b3f0ca Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/d12d56d3-da0d-4c5d-b45a-8580f7b3f0ca Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Applied the proposed updates in
Done — proposed changes are applied in |
|
@copilot Change dockerfile HEALTHCHECK to use curl or wget, whatever is more appropriate in your view (or makes this simpler) |
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/6aaeb26f-7b63-47ec-b505-7c4b43280c81 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Updated in |
| DB_PATH = Path(os.getenv("DB_PATH") or Path("data/database.db")).absolute() | ||
| DB_PATH.parent.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| HEALTHCHECK_HOST = os.getenv("HEALTHCHECK_HOST", "127.0.0.1") |
There was a problem hiding this comment.
If the default is used for these, they will be empty/unset in the docker container and as such it will fail. THey need to be added as ENV in the dockerfile and can be optionally overridden later.
There was a problem hiding this comment.
Addressed in 372b9e5: added Dockerfile ENV HEALTHCHECK_HOST=127.0.0.1 and ENV HEALTHCHECK_PORT=8080 so container defaults are set and can still be overridden.
There was a problem hiding this comment.
The defaults should also be removed from there then. And empty hostname could mean the healthcheck is disabled.
There was a problem hiding this comment.
Applied in e9781b5: removed app-side defaults from src/config.py for HEALTHCHECK_HOST/HEALTHCHECK_PORT, and made an unset/empty HEALTHCHECK_HOST disable the healthcheck server in the cog. Screenshot: no UI changes (backend/config-only change).
|
@copilot Apply the requested changes |
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/a3887bc1-9eae-4159-b51b-265684de04ab Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Applied in |
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Versa-Bots/versa/sessions/56e0aa53-8e42-43cb-80a0-de126250306f Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
This adds an HTTP healthcheck surface for deployments (Coolify) so the bot can be monitored externally for runtime degradation, not just process liveness. The endpoint supports
GET /healthand reports unhealthy when core dependencies are degraded.Healthcheck server and response contract
src/runtime_healthcheck.py) with configurable host/port.GET /health→ health payload (200or503)404405is_ws_ratelimited())Bot lifecycle integration
src/cogs/healthcheck.py) via@discord.Cog.listener(once=True)on connect.src/__main__.pystops the server through the healthcheck cog while preserving exception-group behavior.HEALTHCHECK_HOSTunset or setting it to an empty string.Configuration and deployment defaults
src/config.py:HEALTHCHECK_HOST(no app-side default; optional)HEALTHCHECK_PORT(no app-side default; required only whenHEALTHCHECK_HOSTis configured)HEALTHCHECK_PORTfails fast only when healthcheck is enabled..env.exampleand README healthcheck docs to reflect fixed/healthpath and disable behavior.8080inDockerfilefor platform probing.HEALTHCHECKinDockerfileusingwgetagainsthttp://${HEALTHCHECK_HOST}:${HEALTHCHECK_PORT}/health.ENVdefaults forHEALTHCHECK_HOSTandHEALTHCHECK_PORTso container health probes work out of the box while remaining overridable.Documentation
Typing cleanup
HealthcheckServerandHealthcheckCog).