- Which endpoints to use
- How to configure liveness and readiness probes (Kubernetes)
- How to configure Docker health checks
- How graceful shutdown (SIGTERM) works in the backend and forecast services
Health endpoints overview
Databrain services expose simple JSON health endpoints:- Backend (Express API) – default port
3000GET /health/live– livenessGET /health/ready– readiness (checks Hasura, Postgres via Hasura, and Keycloak if configured)
- Forecast service (FastAPI) – default port
8082GET /health/liveGET /health/ready
- Hasura
GET /healthz– built-in Hasura health
- App (frontend)
GET /– static app root
For self-hosted deployments, replace host and ports with your actual values. If you run the backend behind a prefix (e.g./api), the health paths become/api/health/liveand/api/health/ready.
Kubernetes configuration
This section shows typical probe configuration for a Kubernetes deployment. Adjust ports and paths to match your manifests.Hasura deployment
Use the built-in/healthz endpoint for both liveness and readiness:
Note: the backend uses Hasura’shealthz?strict=trueinternally when evaluating Postgres health. Do not add query strings like?strict=truedirectly to KuberneteshttpGetprobes – some Kubernetes versions URL-encode?which can break routing. Use plain/healthzin the probe and rely on the backend’s/health/readyfor strict DB checks.
Backend deployment (Express API)
The backend mounts health endpoints at/health. Recommended probes:
- Liveness (
/health/live)- Returns
{ "status": "live" }with HTTP 200 when the process is running. - Does not perform dependency checks.
- Returns
- Readiness (
/health/ready)- Returns HTTP 200 and
{ "status": "ready", "checks": { ... } }when:- Hasura is reachable (
/healthz) - Postgres is healthy via Hasura strict health
- Keycloak is healthy (if configured)
- Hasura is reachable (
- Returns HTTP 503 and
{ "status": "not_ready", "checks": { ... } }when any check is failing.
- Returns HTTP 200 and
Forecast deployment (FastAPI)
The forecast service is a separate FastAPI app with its own health endpoints:GET /health/livereturns{ "status": "live" }.GET /health/readyreturns{ "status": "ready" }when the app is initialized and can accept requests.
App deployment (frontend)
For the frontend container, it’s usually enough to probe the root URL:Docker / Docker Compose health checks
For non-Kubernetes self-hosted setups, use Docker health checks with the same endpoints.Backend (Express API)
Forecast service (FastAPI)
Hasura
App (frontend)
Graceful shutdown & SIGTERM behavior
Recent backend changes added graceful shutdown handling for the Express API and improved lifecycle hooks for the forecast service.Backend (Express API)
Behavior (fromserverless/express/src/index.ts):
- On
SIGTERMorSIGINT:- Logs:
<signal> signal received: closing HTTP server. - Calls
server.close():- Stops accepting new connections.
- Allows in-flight requests to complete.
- When the server is closed:
- Logs
HTTP server closed. - Calls
process.exit(0).
- Logs
- Logs:
- A 30-second timeout is started:
- If shutdown is not complete within 30 seconds:
- Logs
Could not close connections in time, forcefully shutting down. - Calls
process.exit(1).
- Logs
- If shutdown is not complete within 30 seconds:
- Set
terminationGracePeriodSecondsto at least 35 seconds for the backend pod.- This gives the app enough time to drain connections and exit cleanly after receiving
SIGTERM.
- This gives the app enough time to drain connections and exit cleanly after receiving
Forecast service (FastAPI)
Behavior (fromforecast-timeseries/api.py):
- Uses a FastAPI
lifespancontext manager:- On startup: prints
Starting up Forecast service.... - On shutdown: prints
Shutting down Forecast service.... - This is where you can extend logic to close external resources (LLM clients, DB connections, etc.).
- On startup: prints
- Use the same
terminationGracePeriodSeconds/stop_grace_period(35s) pattern as the backend.
Summary
- Use
/health/livefor liveness,/health/readyfor readiness. - For strict database checks, rely on the backend’s
/health/ready, which already queries Hasura and Postgres. - Configure Kubernetes and Docker health checks against these endpoints.
- Ensure termination grace periods are ≥ 35s so graceful shutdown on
SIGTERMcan complete without forced kills.

