Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Health checks and the heal stack

Fleet has no single health endpoint; it has a health surface per layer, and the right check depends on which layer you doubt. This chapter lists every surface, then describes the self-healing chain that keeps a sandbox seat’s broker stack alive. For symptom-driven diagnosis, see Troubleshooting. For how the services are run, see Running the brokers as services.

Every health surface

SurfaceCommand / routeWhat it proves
Queue as a client sees itfleet queue health [--queue <name>] [--worker <id>]The queue client can reach the broker (POST /health) and the broker’s health rows come back. --worker scopes the answer to that worker’s view. Distinct from the broker’s own unauthenticated probe, below.
Queue-broker livenessGET /healthz on the queue-broker (port 4801 on the laptop)The broker process answers. Unauthenticated — the only unauthenticated queue-broker route. It answers before the Turso backend is up (the backend starts on a separate thread), so it proves liveness, not readiness.
Secrets-broker readinessGET /health on the secrets-broker (port 4800)Returns {ok, serving, secrets, last_refresh_unix, refreshing, oldest_secret_age_seconds}. 503 while serving is false — serving becomes true only once at least one refresh has succeeded. Before that, the body carries refresh_error when a refresh has failed. A live process whose bws cannot run is not serving, and this endpoint says so.
Session-broker (proxy) livenessfleet proxy broker hello via fleet init’s probe; the broker also self-checks its peersThe session proxy answers on its socket and speaks the hello/capability handshake. fleet init reporting the proxy role as live is the practical check.
Bridge healthfleet bridge healthThe message bridge’s /healthz answers. No token needed. Proves the bridge service, not your seat’s mailbox access — for that, read a mailbox (fleet bridge inbox --agent <name> --limit 1).
Seat health, all legsfleet agent doctor [--agent <name>]Four independent probes issued together — the legs: bridge (bridge inbox --agent A --limit 1 with a name, else bridge health), queue (queue health), github (gh api rate_limit via fleet gh, falling back to plain signed-in gh), shell (laptop-agent health). There is no secrets leg: secrets is folded into the bridge leg’s stated need. From the legs, doctor derives the rungs map (which intake rungs this seat still has: push = bridge leg, queue = queue leg, shortlist = always true, priority = github leg) and the builds line. Exit 0 when any intake rung is live, else 3.
gh cache daemonfleet gh cache-statusProbes the gh cache daemon: whether it is running, where it is bound, and its cache state. No daemon is a transport-down answer (exit 3), not a crash.
Laptop-agent daemonfleet laptop-agent healthPrints the daemon’s health JSON verbatim (its GET /health, token-authenticated); exit 0 on an answer. This is the shell leg of doctor and the post-activation check for the laptop-agent deploy profile, which has no unauthenticated health endpoint.
Dispatch servicefleet dispatch statusThe pm-dispatch service’s GET /health body, printed verbatim.
The binary itselffleet version / fleet capabilitiesBuild name, derived version, source revision, and the usable capability set. The first thing to collect when a seat behaves as if a verb or domain were missing — see the stub entry in Troubleshooting.

Two reading rules:

  • Liveness is not readiness. /healthz answering, a process existing, and a port listening are each weaker than the check one layer up. Always confirm with the highest surface that matches the complaint: a queue complaint gets fleet queue health, a seat complaint gets fleet agent doctor.
  • 503 from the secrets-broker is information, not failure. It distinguishes “not loaded yet” from “no such secret” (404) and from “the source failed” (502). Clients key on it; so should you.

The heal stack (sandbox seat)

A sandbox seat’s broker stack has several moving parts between a fleet command and the laptop, and any of them can die with the seat’s runtime. The heal chain rebuilds them in dependency order:

tailscaled → relay :3130 → session broker → secrets broker → gh
  1. tailscaled — the tailnet itself. Nothing downstream works without it.
  2. The relay on port 3130 — a local relay that carries the seat’s session-proxy traffic to the tailnet proxy. Userspace-networking seats route the session proxy through a CONNECT proxy fleet expects on port 3130; the relay is what makes that port answer.
  3. The session broker — the session proxy broker process (fleet serve proxy), spawned via fleet init when its socket does not answer (see Running the brokers as services).
  4. The secrets broker — the seat’s loopback secrets-broker, spawned the same way when its socket does not answer.
  5. gh — the gh command shim and the pristine gh binary it routes to; the chain verifies both exist and answer, because a shim whose target is missing fails every gh call at once.

Order matters: starting the session broker before the relay is up produces a broker that cannot reach anything; starting the secrets broker before the session broker leaves secret consumers with nowhere to ask. The chain is therefore run whole, in this order, never piecemeal by hand.

The 5-minute heal cron

A cron job on the seat runs the heal check roughly every five minutes. Each run verifies channel health (the chain above), secrets health (the secrets-broker answering and serving), and gh. A healthy run is silent. An unhealthy leg is rebuilt by the same chain the bootstrap uses — the heal is a re-run of the bring-up for the dead leg and everything downstream of it, not a separate repair implementation.

init-ensure

init-ensure is the bring-up the heal cron and the bootstrap share. It:

  1. Test-executes fleet binary candidates before trusting one (a file can list as executable and still fail to execute, for example when its interpreter is absent), and points the seat’s gh entry point at a working binary.
  2. Delegates the channel to the heal chain above (tailscaled, relay, session broker).
  3. Fetches the secrets-broker token by name from Bitwarden Secrets Manager when the local token file is missing, so the secrets broker can start authenticated.
  4. Ensures the secrets broker and the gh route, completing the five legs.

The bootstrap’s boot hook re-runs the tailnet and fleet phases after a sandbox recycle under a lock with a timeout, because only the home directory survives a recycle. Between recycles, the 5-minute heal cron is what keeps the stack honest.

What to do when healing does not converge

  1. Run fleet agent doctor and note which legs are down — the heal chain fixes legs in order, so the first down leg is the one to look at.
  2. Check the leg’s own surface from the table above (for example fleet gh cache-status for the gh leg, /health for the secrets-broker).
  3. Do not restart-loop a broker that is up but not serving; see the secrets-refresh entry in Troubleshooting.
  4. If the channel itself (tailscaled / relay) is the first down leg and healing does not restore it, the seat cannot reach the laptop at all: queue and broker work will fail with transport errors (exit 3) while purely local work (the shortlist rung) still functions. That state is a channel outage, not a fleet bug — report it as such, with the doctor output attached.