What’s inside a gateway
A gateway deployment is a set of Docker containers that work together:Gateway container
Runs OpenClaw (agent runtime), Chrome/Chromium, XFCE desktop, noVNC (remote desktop), and the files API. This is where agents actually execute.
Dispatcher daemon
Subscribes to
agent_inbox_items via Supabase Realtime. When new work arrives (task assignments, comment mentions, routines), it wakes the right agent on this gateway. Includes burst-aware batch sizing, inbox deduplication, and backoff for unprovisioned agents to prevent resource exhaustion.Runner daemon
Subscribes to
agent_commands via Supabase Realtime. Leases and executes lifecycle commands: provision, update, remove, provider auth, shell commands, gateway operations. Also runs heartbeat (every 30s) and secrets sync.Embedder
Runs a local embedding model (default:
BAAI/bge-small-en-v1.5). Leases knowledge items pending indexing, generates vector embeddings, and creates chunks. HTTP server at :9100.File processor
Leases knowledge items with
kind='file' and processing_status='ready', downloads from Supabase Storage, extracts text (PDF, DOCX, XLSX, CSV, PPTX, TXT), and triggers embedding.Shared state volume
Holds OpenClaw config, the local bare git repo with per-agent branches, browser profiles, desktop files, auth tokens, and secrets.
How gateways communicate
Gateways are pull-based — they don’t receive inbound connections from the UI. All coordination flows through Supabase:Gateway lifecycle
Boot sequence
When a gateway container starts,entrypoint.sh runs a multi-step boot sequence:
- Resolve Supabase credentials (env, token exchange, or workspace registry) 0b. Restore from backup — if no local agent state exists, check Supabase Storage for a previous backup and extract it (restores auth tokens, configs, secrets, Telegram pairing)
- Seed the local bare git repo from
/opt/templates/(or$TEMPLATES_SOURCE) - Optionally attach to
$GIT_REMOTE_URLfor branch backup - Optionally bring up Tailscale (
$TAILSCALE_AUTH_KEY) - Run
openclaw onboard(first boot only) - Patch
openclaw.jsonwith browser, channel, and plugin paths - Install the hq-bootstrap plugin
- Start Xtigervnc + XFCE desktop
- Start websockify → noVNC
- Upsert this gateway’s row in the
gatewaystable with reachable URLs - Exec
openclaw gateway startas the main process
Heartbeat
The runner daemon writeslast_heartbeat_at to the gateways table every 30 seconds. The UI uses this to show gateway health:
- Healthy (green) — heartbeat within 90 seconds
- Stale (amber) — status is
readybut heartbeat is old - No signal — gateway has never reported
Keepalive (hosted/E2B)
For gateways running in hosted mode (E2B sandboxes), a keepalive daemon maintains the sandbox lifecycle. It performs periodic health checks and renewal requests to prevent the sandbox from being reclaimed. The keepalive supports pause/resume functionality — when no agents are actively running, the keepalive can be paused to reduce overhead, and it automatically resumes when new work arrives.Registration
Gateways register with Supabase via a one-time token exchange. The UI generates a token (Settings → Gateways → Add Gateway), the gateway installer callsconsume_gateway_token() to atomically convert the token into a gateways row, and the gateway stores its GATEWAY_ID in .env for all future operations.
One workspace, many gateways
A single HQ workspace can have multiple gateways on different hosts — different machines, different data centers, different continents. Each gateway registers itself in thegateways table with its reachable URLs, so the UI knows how to reach each one.
Agents are bound to a specific gateway via gateway_id. The dispatcher and runner filter their Supabase subscriptions by GATEWAY_ID — no gateway ever picks up another gateway’s work.
Common multi-gateway patterns:
Gateway state and persistence
Each gateway owns a Docker volume (gateway-state) that holds:
- Git repo — a bare repo with one branch per agent. Agent files, skills, memory, and identity all live here.
- Browser profiles — Chrome profiles persist cookies, logins, and localStorage across agent sessions.
- Auth tokens — model provider credentials (OpenAI, Anthropic, etc.) stored by OpenClaw.
- Secrets — decrypted
.envfiles written by the secrets sync daemon (plaintext on disk,chmod 0600). - Desktop state — XFCE config, wallpapers, shortcuts.
Automatic backup & restore
Since v0.2.1, gateway state is automatically backed up to Supabase Storage on every shutdown and restored on fresh boot. The backup includes auth tokens, agent configs, secrets, and Telegram pairing data. It excludessessions and codex-home directories to keep backups small.
Retention policy: 3 backups per gateway, 7-day max age, newest-first restore with fallback to older backups if the most recent is corrupted. You can also trigger manual backups and view backup status from Settings → Backups in the UI.
If you lose the gateway-state volume, the gateway will automatically restore from the most recent backup on next boot — no manual intervention needed. Agents can also be reprovisioned from the database if no backup is available. Use GIT_REMOTE_URL to continuously back up agent branches to GitHub/Gitea for an additional layer of protection. See Operations → Backing up.
Adding a gateway
The recommended path is UI-driven:- Settings → Gateways → Add Gateway.
- Copy the generated installer command.
- Run it on the new host.

