openclaw gateway

Gateway 的 WebSocket 服务器管理命令(channel、node、session、hook)。

启动 Gateway

openclaw gateway          # 前台运行
openclaw gateway run      # 同上(别名)
openclaw gateway --allow-unconfigured  # 跳过 gateway.mode=local 检查(开发用)
openclaw gateway --force  # 杀掉已占用端口的进程后启动

启动要求:openclaw.json 中必须设置 gateway.mode=local,否则拒绝启动(防止意外暴露)。

重启

openclaw gateway restart              # 服务管理器重启
openclaw gateway restart --safe       # 等待活跃任务排空后重启
openclaw gateway restart --safe --skip-deferral  # 强制立即重启(卡住任务的逃生通道)
openclaw gateway restart --force      # 跳过排空,立即重启

服务管理

openclaw gateway install    # 安装系统服务(launchd/systemd/schtasks)
openclaw gateway start
openclaw gateway stop       # --disable 可持久禁用 KeepAlive
openclaw gateway restart
openclaw gateway uninstall

使用 wrapper 安装(适合 secrets manager 场景):

openclaw gateway install --wrapper ~/.local/bin/openclaw-doppler --force

查询运行中的 Gateway

所有查询命令通过 WebSocket RPC,共享选项:--url、--token、--password、--timeout

openclaw gateway health --url ws://127.0.0.1:18789
openclaw gateway status
openclaw gateway status --require-rpc   # 脚本中验证 RPC 可用性
openclaw gateway probe                  # 调试所有可达 gateway
openclaw gateway probe --ssh user@host  # 通过 SSH 隧道探测远程 gateway
openclaw gateway usage-cost --days 7
openclaw gateway stability --bundle latest
openclaw gateway diagnostics export    # 生成诊断 zip(用于 bug 报告)
openclaw gateway call status           # 低级 RPC 调用

健康端点

  • /healthz:存活探针,服务能响应 HTTP 即返回
  • /readyz:就绪探针,等待插件 sidecar、channel、hook 全部就绪

Bonjour 发现

openclaw gateway discover
openclaw gateway discover --json | jq '.beacons[].wsUrl'

扫描 _openclaw-gw._tcp,支持本地 mDNS(local.)和广域 DNS-SD。

启动诊断

OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw gateway  # 输出各阶段耗时

相关链接