P1: Add readiness probe distinct from liveness (#169)#187
Open
dkijania wants to merge 1 commit into
Open
Conversation
`/healthcheck` is Yoga's built-in liveness check — it only confirms the process is serving HTTP, not that the database is reachable. An orchestrator therefore keeps routing traffic to an instance whose Postgres is down. Add a `/readiness` endpoint that pings the database (`SELECT 1`) and returns 200 when it answers, 503 otherwise. A lightweight `ping()` is added to the database adapter (resolves false instead of throwing). The readiness plugin is prepended to the plugin list so probes short-circuit before any other request hook (e.g. rate limiting) can interfere. Use `/healthcheck` for the Kubernetes liveness probe and `/readiness` for the readiness probe: a node with an unreachable DB reports not-ready (stops getting traffic) while staying live (not needlessly restarted). Docs updated; unit tests cover 200/503 and confirm normal GraphQL requests pass through untouched. Closes #169. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSuak9smCHbp4N17xjjLF6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Part of the production-readiness epic (#163). Closes #169.
/healthcheckis Yoga's built-in liveness check — it only confirms the process is serving HTTP, not that the database is reachable. An orchestrator therefore keeps routing traffic to an instance whose Postgres is down.Changes
/readinessendpoint (src/server/readiness.ts) that pings the DB and returns 200 when it answers, 503 otherwise.ping()added to the database adapter — runsSELECT 1, resolvesfalseinstead of throwing.Probe usage
/healthcheck/readinessSELECT 1)A node with an unreachable DB reports not-ready (stops getting traffic) while staying live (not needlessly restarted).
Testing
npm run build— cleannpm run test:unit— all pass (200/503 end-to-end through Yoga; confirms normal GraphQL requests are not intercepted)npm run lint— cleannpx prettier --debug-check .— exit 0🤖 Generated with Claude Code