Repository navigation
feat(server): add opt-in /health/live and /health/ready endpoints - #351
Merged
Merged
Conversation
useHealth = True serves two endpoints for load balancers and Kubernetes probes. /health/live answers 200 while the process answers. /health/ready answers 200 once the application has started and 503 while it starts or is asked to stop, read from the ASGI lifespan messages. The middleware is the outermost one, so a probe skips the access log, the trusted host check and the HTTPS redirect, and the endpoints are not in the OpenAPI schema. The setting is off by default: no path is taken from a project that does not set it. Closes #86
Regenerated with scripts/translate_docs.py for docs/deployment/README.md and docs/reference/config.md in every site language.
This was referenced Nov 14, 2026
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.
Description
Adds an opt-in
useHealthsetting that serves two endpoints for load balancers and Kubernetes probes.GET /health/liveanswers 200 while the process answers.GET /health/readyanswers 200 once the application has started, and 503 while it starts or is asked to stop. The phase is read from the ASGI lifespan messages, so it follows the real startup and shutdown.The middleware is the outermost one, so a probe is answered before the access log,
useTrustedHostanduseHTTPSRedirect. A probe sent over HTTP to the address of a pod is therefore not refused. No route is added, so the endpoints stay out of the OpenAPI schema.useHealthisFalseby default, so no path is taken from a project that does not set it.docs/deployment/README.mdgets a "Built-in endpoints" section with a KubernetesDeploymentprobe example, anddocs/reference/config.mdgets auseHealthrow.Fixes #86
Type of change
Checklist
python -m pytest tests/ -v), apart from 6test_make_com_mediatests that also fail onmainon my machine because the DejaVu fonts are missingruff check nexy/)python -m mypy nexy --strict)ruff format nexy/ --check)Additional context
tests/unit/nexy/routers/test_health.py: the starting, ready and stopping lifecycle, the access log, the host check and HTTPS redirect, the OpenAPI schema, and off by default.docs/<lang>/were regenerated withscripts/translate_docs.pyfor the two pages I changed (33 files, in their own commit). Only the English pages are hand-written.