Add a /health endpoint for container health checks #267
Labels
No labels
bug
duplicate
enhancement
help wanted
high priority
invalid
L
low priority
M
medium priority
needs refinement
optional
question
S
security
technical improvement
UX Improvement
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
local-it/mitgliederverwaltung#267
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Problem
Mila has no endpoint that tells a container orchestrator whether the app answers requests. The coop-cloud recipe's health check is commented out (
bin/mv eval "IO.puts(:ok)"boots a separate VM every interval and does not check the running app), and the runtime image has neithercurlnorwget. The recipe can only check that port 4001 is open, which misses an app that accepts connections but no longer answers.Proposal
A plug in
MvWeb.Endpoint, placed beforePlug.RequestIdandPlug.Telemetry, that answersGET /health(andHEAD) with200and the bodyokand halts. It runs before the session, the router and the request logger, so a check every 30 s writes nothing to the log.No database query: when the database is down, restarting the app does not help, and Swarm would only put the app into a restart loop. The database has its own health check.
No authentication, no information in the response (no version, no commit).
Document the endpoint and a check without extra tools in the README (production section):
Add the same check to
docker-compose.prod.yml.Related, outside this repository
The coop-cloud recipe sets
PHX_SERVER: "true"for the whole container. Then thebin/mv evalsteps ofdocker-entrypoint.sh(seeds, admin user) also start the web server, so port 4001 answers before the app has finished starting. The recipe should drop that variable (bin/serversets it itself); once a release with/healthexists, it switches from the port check to the check above.Acceptance criteria
GET /healthreturns200withokwithout a session, also when the request has noHostmatchingPHX_HOST; it writes no request log line./healthanswers without touching the database (e.g. with the repo checked out but unused) and that the response contains no version information.docker-compose.prod.ymlshow the health check.Improve compatibility with cloud deploymentsto Add a /health endpoint for container health checks