feat: /healthz route and Dockerfile HEALTHCHECK #36
No reviewers
Labels
No labels
bug
docs
duplicate
enhancement
help wanted
invalid
nice-to-have
pre-1.0
question
security
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jfro/lamplighter!36
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/17-healthz"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #17
What
LamplighterWeb.Healthzplug, first in the endpoint (ahead of Static, Telemetry, session and the router):GET/HEAD /healthz, no auth, no cookie, not in the request log.200 {"status":"ok","checks":{"database":"ok"}}whenSELECT 1succeeds within 2s;503 {"status":"error","checks":{"database":"error"}}otherwise.Cache-Control: no-store.DBConnection.ConnectionError, exit) loghealthz: database check failed after Nms: <reason>at error level. The reason never goes in the response body.rel/overlays/bin/healthcheck: bash/dev/tcpprobe of127.0.0.1:$PORT/healthz, exit 0 only on 200, reason on stderr (shows indocker inspect). The final image has no curl, so no new package.HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3.force_ssl, and the plug runs before the browser pipeline.Checked
mix precommit: 800 passed;mix format --check-formattedclean.healthz_test.exs: 200 path, HEAD, POST and/healthz/extrafall through to 404, 503 + log for down/raising/exiting repos, no reason leak.curl /healthz→ 200;bin/healthcheck→ exit 0; against a server returning 404 → exit 1 with the status line; nothing listening → exit 1. No healthz lines in the request log.Docker check on the built image (
docker buildat3ddf82c):docker inspect→healthy, probe exit 0.RUN_MIGRATIONS=false): probe →healthcheck: HTTP/1.0 503 Service Unavailable, app logshealthz: database check failed after 2964ms: ... connection not available and request was dropped from queue.Note: with the pool unable to connect, DBConnection's queue gives up at ~3s (before the 2s query timeout applies), still inside the 5s HEALTHCHECK timeout.