Last updated

Health checks

Windshift exposes a liveness endpoint and a readiness endpoint. Both are public, both honour WINDSHIFT_CONTEXT_PATH, and they answer different questions.

Endpoint Question it answers Fails when
GET /healthz Is the process up and serving HTTP? The server cannot answer at all.
GET /readyz Should this instance receive traffic? The database is unusable.

Readiness is deliberately forgiving about dependencies other than the database. If attachment storage is unreachable — an S3 outage, for example — /readyz still returns HTTP 200 and marks the response degraded. The instance stays in rotation and keeps serving requests that do not need attachments, which is the right trade for a single-instance self-hosted deployment: taking the app out of service because a bucket is down would remove working functionality too.

The healthcheck command

The binary can probe itself, which is what the container health check uses:

windshift healthcheck

It exits successfully only when /readyz returns HTTP 200, so an unready database makes it fail. The default target is http://127.0.0.1:${PORT:-8080}/readyz.

The public BASE_URL is not used. Plain HTTP and reverse-proxy TLS deployments both probe loopback HTTP directly, because TLS belongs at the edge.

Set WINDSHIFT_CONTEXT_PATH for prefixed deployments. A context path of /windshift changes the probe target to /windshift/readyz — the same applies to the container HEALTHCHECK, so the two stay aligned.

Direct TLS

Set both TLS_CERT and TLS_KEY in the server and health check environment when Windshift itself serves HTTPS. These variables also configure the server's TLS listener, so the container health check speaks the same protocol automatically:

export PORT=8443
export TLS_CERT=/run/secrets/windshift-cert.pem
export TLS_KEY=/run/secrets/windshift-key.pem
windshift healthcheck

The health check connects to loopback HTTPS and pins the first certificate in TLS_CERT. The presented leaf must match exactly, even though its public hostname will not match 127.0.0.1. Certificate chains and key-before-certificate PEM bundles are supported. Verification is not disabled for other HTTP clients.

If the server uses --tls-cert/--tls-key flags instead, give the health check the equivalent environment variables — it does not read the server's command-line flags. Do not set these variables when TLS terminates at a reverse proxy.

Explicit target

An optional argument replaces the default URL, including its path:

windshift healthcheck http://127.0.0.1:8080/windshift/readyz

With the direct-TLS environment variables set, the certificate pin still applies. Without them, HTTPS targets use normal system certificate verification.

Wiring it up

  • Docker and Compose: the official image declares a health check that runs windshift healthcheck. Keep it — the restore workflow in Backup and restore waits for health before declaring a restore successful, and falls back to running the same command through Compose when Docker exposes no status.
  • Kubernetes: use GET /healthz for liveness and GET /readyz for readiness and startup. The example manifests and their probe settings are covered in Kubernetes.
  • Prometheus: /metrics is separate from these probes and can be token-protected; see Prometheus metrics.