Add /healthz endpoint and Docker HEALTHCHECK #2

Merged
ivan.pavlina merged 1 commit from claude/issue-1 into main 2026-10-15 08:26:35 +02:00

I added GET /healthz and a Docker HEALTHCHECK, and committed them as 98ec248 on claude/issue-1. I could not write the report file. The Write tool was denied permission for /tmp/claude-report-0g5pph1d/report.md, and I did not work around that with another tool. The report text is below.

Changes

  • app/server.py:
    • /healthz returns 200 ok as plain text when the MikroTik poller has a successful poll newer than 3 × poll_interval.
    • Otherwise it returns 503 with stale: <router error> or stale: no data from router.
    • A failed poll stores no data, so a dead router connection fails the check right away.
    • NetFlow is not considered.
  • Dockerfile:
    • The HEALTHCHECK runs every 30s with a 5s timeout, a 30s start period and 3 retries.
    • It runs python3 -c with urllib against 127.0.0.1:$DASHY_PORT/healthz, so there are no new packages.
    • A non-200 response makes urlopen raise, which gives a non-zero exit.
  • CLAUDE.md: documented the endpoint in the Endpoints paragraph. The repo has no README.

Verification

  • I ran the handler in-process and requested /healthz four times:
    • empty store: 503
    • fresh good poll: 200 ok
    • poll 7s old with poll_interval 2: 503
    • failed poll with an error: 503 stale: boom
  • I did not build the Docker image, because there is no Docker here. The HEALTHCHECK command was not run inside a container.

Open

  • Until the first successful poll the endpoint returns 503, so the HEALTHCHECK relies on --start-period=30s to cover startup.
  • The existing log_message logs each 503, so a failing check adds a log line every 30s.
  • CLAUDE.md mentions a healthcheck-cmd="python3 /conf/healthcheck.py" on the RouterOS container. RouterOS does not use the image's HEALTHCHECK, so you can point that at /healthz too if you want. I left it alone.

Closes #1

I added `GET /healthz` and a Docker `HEALTHCHECK`, and committed them as `98ec248` on `claude/issue-1`. I could not write the report file. The Write tool was denied permission for `/tmp/claude-report-0g5pph1d/report.md`, and I did not work around that with another tool. The report text is below. **Changes** - **`app/server.py`:** - `/healthz` returns `200 ok` as plain text when the MikroTik poller has a successful poll newer than 3 × `poll_interval`. - Otherwise it returns `503` with `stale: <router error>` or `stale: no data from router`. - A failed poll stores no data, so a dead router connection fails the check right away. - NetFlow is not considered. - **`Dockerfile`:** - The `HEALTHCHECK` runs every 30s with a 5s timeout, a 30s start period and 3 retries. - It runs `python3 -c` with `urllib` against `127.0.0.1:$DASHY_PORT/healthz`, so there are no new packages. - A non-200 response makes `urlopen` raise, which gives a non-zero exit. - **`CLAUDE.md`:** documented the endpoint in the Endpoints paragraph. The repo has no README. **Verification** - I ran the handler in-process and requested `/healthz` four times: - empty store: 503 - fresh good poll: 200 `ok` - poll 7s old with `poll_interval` 2: 503 - failed poll with an error: 503 `stale: boom` - I did not build the Docker image, because there is no Docker here. The `HEALTHCHECK` command was not run inside a container. **Open** - Until the first successful poll the endpoint returns 503, so the `HEALTHCHECK` relies on `--start-period=30s` to cover startup. - The existing `log_message` logs each 503, so a failing check adds a log line every 30s. - `CLAUDE.md` mentions a `healthcheck-cmd="python3 /conf/healthcheck.py"` on the RouterOS container. RouterOS does not use the image's `HEALTHCHECK`, so you can point that at `/healthz` too if you want. I left it alone. Closes #1
/healthz returns 200 ok while the MikroTik poller has a successful poll
newer than 3 poll intervals, 503 otherwise. NetFlow is not considered.
The HEALTHCHECK uses the image's Python, so no new packages.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Owner

@claude build the image and verify the HEALTHCHECK passes in a running container

@claude build the image and verify the HEALTHCHECK passes in a running container
Owner

@claude build the image and verify the HEALTHCHECK passes in a running container

@claude build the image and verify the HEALTHCHECK passes in a running container
Sign in to join this conversation.
No reviewers
No labels
claude
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ivan.pavlina/dashy!2
No description provided.