Health checks
createCovara mounts two endpoints by default:
| Endpoint | Probe | Meaning |
|---|---|---|
GET /healthz | Liveness | The process is up. Stays 200 even during graceful shutdown. |
GET /readyz | Readiness | The instance is ready to serve traffic. Flips to 503 during shutdown so load balancers drain it. |
Both support HEAD for cheap probes. Wire them into your orchestrator (Kubernetes livenessProbe/readinessProbe, load-balancer health checks).
Configuration
const app = createCovara({
health: {
version: "1.0.0",
checks: {
kv: getGlobalKV(), // dependency checks — included in the readiness result
},
thresholds: {
eventLoopLagMs: 100, // mark unhealthy above this lag
memoryPercent: 90, // mark unhealthy above this memory usage
},
},
});
Pass health: false to disable the endpoints, or health: true for defaults.
checks accepts dependency objects (e.g. the KV store, a database) that the readiness endpoint probes; a failing dependency makes /readyz report unhealthy. thresholds add runtime guards (event-loop lag, memory) on Node.
Response shape
{
"status": "ok",
"version": "1.0.0",
"uptime": 3600,
"checks": { "kv": { "status": "ok" } }
}
Graceful shutdown
On Node, startServer installs SIGTERM/SIGINT handlers that, on shutdown:
- flip readiness so
/readyzreturns503(new traffic stops routing here), - close long-lived SSE subscriptions cleanly so clients reconnect elsewhere,
- wait a bounded drain window (
drainTimeoutMs, default 10s) before closing the listener.
/healthz stays 200 throughout — only /readyz flips — so the orchestrator distinguishes "draining" from "dead". See Node deployment.