Files
openclaw/docs/gateway/index.md

262 lines
7.4 KiB
Markdown
Raw Normal View History

---
2026-01-21 17:45:12 +00:00
summary: "Runbook for the Gateway service, lifecycle, and operations"
read_when:
- Running or debugging the gateway process
title: "Gateway Runbook"
---
2026-01-31 21:13:13 +09:00
# Gateway runbook
2025-12-09 14:41:41 +01:00
Use this page for day-1 startup and day-2 operations of the Gateway service.
2025-12-09 14:41:41 +01:00
<CardGroup cols={2}>
<Card title="Deep troubleshooting" icon="siren" href="/gateway/troubleshooting">
Symptom-first diagnostics with exact command ladders and log signatures.
</Card>
<Card title="Configuration" icon="sliders" href="/gateway/configuration">
Task-oriented setup guide + full configuration reference.
</Card>
<Card title="Secrets management" icon="key-round" href="/gateway/secrets">
SecretRef contract, runtime snapshot behavior, and migrate/reload operations.
</Card>
<Card title="Secrets plan contract" icon="shield-check" href="/gateway/secrets-plan-contract">
Exact `secrets apply` target/path rules and ref-only auth-profile behavior.
</Card>
</CardGroup>
2026-01-31 21:13:13 +09:00
## 5-minute local startup
2025-12-09 14:41:41 +01:00
<Steps>
<Step title="Start the Gateway">
2026-01-31 21:13:13 +09:00
2025-12-09 14:41:41 +01:00
```bash
2026-01-30 03:15:10 +01:00
openclaw gateway --port 18789
# debug/trace mirrored to stdio
2026-01-30 03:15:10 +01:00
openclaw gateway --port 18789 --verbose
# force-kill listener on selected port, then start
2026-01-30 03:15:10 +01:00
openclaw gateway --force
2025-12-09 14:41:41 +01:00
```
2026-01-31 21:13:13 +09:00
</Step>
2025-12-09 14:41:41 +01:00
<Step title="Verify service health">
```bash
openclaw gateway status
openclaw status
openclaw logs --follow
```
2026-01-31 21:13:13 +09:00
Healthy baseline: `Runtime: running` and `RPC probe: ok`.
</Step>
<Step title="Validate channel readiness">
2025-12-09 14:41:41 +01:00
```bash
openclaw channels status --probe
```
</Step>
</Steps>
<Note>
Gateway config reload watches the active config file path (resolved from profile/state defaults, or `OPENCLAW_CONFIG_PATH` when set).
Default mode is `gateway.reload.mode="hybrid"`.
</Note>
## Runtime model
2026-01-31 21:13:13 +09:00
- One always-on process for routing, control plane, and channel connections.
- Single multiplexed port for:
- WebSocket control/RPC
- HTTP APIs (OpenAI-compatible, Responses, tools invoke)
- Control UI and hooks
- Default bind mode: `loopback`.
- Auth is required by default (`gateway.auth.token` / `gateway.auth.password`, or `OPENCLAW_GATEWAY_TOKEN` / `OPENCLAW_GATEWAY_PASSWORD`).
### Port and bind precedence
2026-01-31 21:13:13 +09:00
| Setting | Resolution order |
| ------------ | ------------------------------------------------------------- |
| Gateway port | `--port``OPENCLAW_GATEWAY_PORT``gateway.port``18789` |
| Bind mode | CLI/override → `gateway.bind``loopback` |
### Hot reload modes
| `gateway.reload.mode` | Behavior |
| --------------------- | ------------------------------------------ |
| `off` | No config reload |
| `hot` | Apply only hot-safe changes |
| `restart` | Restart on reload-required changes |
| `hybrid` (default) | Hot-apply when safe, restart when required |
2026-01-05 01:25:42 +01:00
## Operator command set
2026-01-05 01:25:42 +01:00
```bash
openclaw gateway status
openclaw gateway status --deep
openclaw gateway status --json
openclaw gateway install
openclaw gateway restart
openclaw gateway stop
openclaw secrets reload
openclaw logs --follow
openclaw doctor
2026-01-05 01:25:42 +01:00
```
## Remote access
2026-01-31 21:13:13 +09:00
Preferred: Tailscale/VPN.
Fallback: SSH tunnel.
2026-01-05 01:25:42 +01:00
```bash
ssh -N -L 18789:127.0.0.1:18789 user@host
```
2026-01-31 21:13:13 +09:00
Then connect clients to `ws://127.0.0.1:18789` locally.
2026-01-05 02:03:10 +01:00
<Warning>
If gateway auth is configured, clients still must send auth (`token`/`password`) even over SSH tunnels.
</Warning>
2026-01-31 21:13:13 +09:00
See: [Remote Gateway](/gateway/remote), [Authentication](/gateway/authentication), [Tailscale](/gateway/tailscale).
## Supervision and service lifecycle
2026-01-31 21:13:13 +09:00
Use supervised runs for production-like reliability.
<Tabs>
<Tab title="macOS (launchd)">
2026-01-31 21:13:13 +09:00
```bash
openclaw gateway install
openclaw gateway status
openclaw gateway restart
openclaw gateway stop
```
LaunchAgent labels are `ai.openclaw.gateway` (default) or `ai.openclaw.<profile>` (named profile). `openclaw doctor` audits and repairs service config drift.
2025-12-09 14:41:41 +01:00
</Tab>
2026-01-31 21:13:13 +09:00
<Tab title="Linux (systemd user)">
2025-12-09 14:41:41 +01:00
```bash
openclaw gateway install
systemctl --user enable --now openclaw-gateway[-<profile>].service
openclaw gateway status
```
2026-01-31 21:13:13 +09:00
For persistence after logout, enable lingering:
2025-12-09 14:41:41 +01:00
```bash
sudo loginctl enable-linger <user>
```
2026-01-31 21:13:13 +09:00
</Tab>
2025-12-09 14:41:41 +01:00
<Tab title="Linux (system service)">
2026-01-31 21:13:13 +09:00
Use a system unit for multi-user/always-on hosts.
2025-12-09 14:41:41 +01:00
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now openclaw-gateway[-<profile>].service
```
2026-01-31 21:13:13 +09:00
</Tab>
</Tabs>
2025-12-09 14:41:41 +01:00
## Multiple gateways on one host
2026-01-31 21:13:13 +09:00
Most setups should run **one** Gateway.
Use multiple only for strict isolation/redundancy (for example a rescue profile).
2025-12-09 14:41:41 +01:00
Checklist per instance:
2026-01-31 21:13:13 +09:00
- Unique `gateway.port`
- Unique `OPENCLAW_CONFIG_PATH`
- Unique `OPENCLAW_STATE_DIR`
- Unique `agents.defaults.workspace`
2025-12-09 14:41:41 +01:00
Example:
2026-01-31 21:13:13 +09:00
```bash
OPENCLAW_CONFIG_PATH=~/.openclaw/a.json OPENCLAW_STATE_DIR=~/.openclaw-a openclaw gateway --port 19001
OPENCLAW_CONFIG_PATH=~/.openclaw/b.json OPENCLAW_STATE_DIR=~/.openclaw-b openclaw gateway --port 19002
```
2025-12-09 14:41:41 +01:00
See: [Multiple gateways](/gateway/multiple-gateways).
2026-01-07 21:37:05 +01:00
### Dev profile quick path
2026-01-07 21:37:05 +01:00
```bash
openclaw --dev setup
openclaw --dev gateway --allow-unconfigured
openclaw --dev status
2026-01-07 21:37:05 +01:00
```
Defaults include isolated state/config and base gateway port `19001`.
2026-01-31 21:13:13 +09:00
## Protocol quick reference (operator view)
2026-01-07 21:37:05 +01:00
- First client frame must be `connect`.
- Gateway returns `hello-ok` snapshot (`presence`, `health`, `stateVersion`, `uptimeMs`, limits/policy).
- Requests: `req(method, params)``res(ok/payload|error)`.
- Common events: `connect.challenge`, `agent`, `chat`, `presence`, `tick`, `health`, `heartbeat`, `shutdown`.
2026-01-31 21:13:13 +09:00
Agent runs are two-stage:
2025-12-19 19:20:57 +01:00
1. Immediate accepted ack (`status:"accepted"`)
2. Final completion response (`status:"ok"|"error"`), with streamed `agent` events in between.
2026-01-31 21:13:13 +09:00
See full protocol docs: [Gateway Protocol](/gateway/protocol).
## Operational checks
2026-01-31 21:13:13 +09:00
### Liveness
2026-01-31 21:13:13 +09:00
- Open WS and send `connect`.
- Expect `hello-ok` response with snapshot.
2026-01-31 21:13:13 +09:00
### Readiness
2026-01-31 21:13:13 +09:00
```bash
openclaw gateway status
openclaw channels status --probe
openclaw health
```
### Gap recovery
2026-01-31 21:13:13 +09:00
Events are not replayed. On sequence gaps, refresh state (`health`, `system-presence`) before continuing.
## Common failure signatures
| Signature | Likely issue |
| -------------------------------------------------------------- | ---------------------------------------- |
| `refusing to bind gateway ... without auth` | Non-loopback bind without token/password |
| `another gateway instance is already listening` / `EADDRINUSE` | Port conflict |
| `Gateway start blocked: set gateway.mode=local` | Config set to remote mode |
| `unauthorized` during connect | Auth mismatch between client and gateway |
2025-12-09 14:41:41 +01:00
For full diagnosis ladders, use [Gateway Troubleshooting](/gateway/troubleshooting).
2025-12-09 14:41:41 +01:00
## Safety guarantees
2026-01-31 21:13:13 +09:00
- Gateway protocol clients fail fast when Gateway is unavailable (no implicit direct-channel fallback).
- Invalid/non-connect first frames are rejected and closed.
- Graceful shutdown emits `shutdown` event before socket close.
2025-12-09 14:41:41 +01:00
---
2025-12-09 14:41:41 +01:00
Related:
2026-01-31 21:13:13 +09:00
- [Troubleshooting](/gateway/troubleshooting)
- [Background Process](/gateway/background-process)
- [Configuration](/gateway/configuration)
- [Health](/gateway/health)
- [Doctor](/gateway/doctor)
- [Authentication](/gateway/authentication)