Health check endpoints for relays

Expose liveness and readiness routes so Docker, uptime robots, and you know when cache or upstream probes fail.

A relay can hang with a 200 OK on stale JSON. Good health endpoints distinguish **process up**, **Redis reachable**, and **recent successful upstream poll**. Home-lab monitors and Compose restart policies depend on meaningful HTTP status codes—not just TCP open on port 443.

Health check flow from monitor to relay to Redis and upstream Arduino
Liveness confirms the app runs; readiness verifies cache connectivity and fresh upstream data.

Suggested routes

  • GET /health/live — returns 200 if event loop responsive.
  • GET /health/ready — checks Redis ping and upstream fetch within TTL.
  • GET /health/metrics — optional Prometheus text for advanced users.

Status code policy

Return **503** when last good upstream sample is older than two TTL windows—site logic in stale reading debug aligns. Log upstream errors separately from client traffic per relay security.

Website integration

The Astro fetch layer may still show cached values briefly—see caching feed responses. Health endpoints help operators, not end users; configure monitors outside the public home page.