一句话定义

  • 这一组命令负责把 OpenClaw 跑起来、看它是否健康、看日志、排查故障,以及打开控制界面。

解决的问题

  • Gateway 有没有启动成功
  • Gateway 只是“进程活着”,还是 RPC 真的可用
  • 当前 channels / sessions / usage 状态如何
  • 出问题时该先看哪里、先跑什么命令

核心机制

  • gateway 是当前版本的服务管理主入口。
  • status / health / logs / doctor 是最常用的排错闭环。
  • dashboard / tui / docs 分别对应可视化控制台、终端交互界面、文档检索。tui 别名有 terminal 和 chat;tui 现在支持 --local、--message、--session、--thinking、--timeout-ms、--deliver、--url、--token、--password。
  • daemon 仍存在,但属于 legacy alias,文档与日常习惯上优先用 gateway

关键组成

1. Gateway 服务命令

openclaw gateway status
openclaw gateway start
openclaw gateway stop
openclaw gateway restart
openclaw gateway run --verbose
openclaw gateway probe
openclaw gateway discover

用途拆解:

  • gateway status:查看服务状态,并可附带 RPC 探测
  • gateway start/stop/restart:服务启停控制
  • gateway run:前台运行,适合调试
  • gateway probe:排查“能否连接 / RPC 是否可用 / 是否 scope 受限”
  • gateway discover:发现网络中的 gateway 广播

2. 综合状态与健康检查

openclaw status
openclaw status --deep
openclaw status --usage
openclaw health
openclaw doctor

用途拆解:

  • status:看整体运行概况
  • status --deep:对 channels 做更深探测
  • status --usage:看模型提供商使用量/额度快照
  • health:从运行中的 gateway 获取健康状态
  • doctor:做健康检查和常见修复

3. 日志与调试界面

openclaw logs
openclaw logs --follow
openclaw logs --json
openclaw tui|terminal|chat
openclaw tui --local
openclaw tui --message "hello" --session work
openclaw docs <query>

用途拆解:

  • logs --follow:实时跟日志,排错高频命令
  • logs --json:脚本化或结构化分析日志
  • dashboard:打开 Web 控制台
  • tui|terminal|chat:进入终端 UI(三个别名等价)
    • --local:本地嵌入 agent 运行时
    • --message:连接后立即发送初始消息
    • --session:指定会话 key
    • --deliver:投递助手回复
    • --thinking:覆盖思考级别
    • --timeout-ms:agent 超时
    • --url / --token / --password:远程 Gateway 连接
  • docs:快速搜索官方文档

生命周期 / 执行流程

日常巡检流程

  1. openclaw status
  2. 若异常不明显,执行 openclaw gateway status
  3. 再看 openclaw health
  4. 继续用 openclaw logs --follow 追日志
  5. 若怀疑配置或环境问题,执行 openclaw doctor

Gateway 起不来时

  1. openclaw gateway status
  2. openclaw gateway run --verbose
  3. 同时关注端口占用、auth 配置、SecretRef 是否解析成功
  4. 若只是日常改完配置,通常 openclaw gateway restart 即可

远程 / 多 gateway 排查时

  1. openclaw gateway probe
  2. 必要时 openclaw gateway discover
  3. 如果要严格要求 RPC 可用,用 openclaw gateway status --require-rpc

高频命令组合

最小排错组合

openclaw status
openclaw gateway status
openclaw logs --follow

稍完整的诊断组合

openclaw status --deep
openclaw health
openclaw gateway probe
openclaw doctor

调试运行组合

openclaw gateway run --verbose
openclaw tui --local
openclaw gateway call health
openclaw gateway stability

边界与限制

  • gateway status 看的是服务与探测结果,不等于应用层所有能力都正常。
  • status --deep 会做更多探测,适合排错,不一定适合高频无脑执行。
  • logs 依赖 gateway RPC;如果 RPC 本身不可用,就要优先解决 gateway 连通性。
  • dashboard 更适合可视化巡检,不替代命令行精确排错。

常见误区

  • 误区 1:把 daemon 当作唯一正确入口。实际上当前主入口是 gateway
  • 误区 2:只看 gateway status 就认为系统没问题。很多时候还要看 statushealthlogs
  • 误区 3:日志没报错就说明没问题。权限、认证、scope 不足也可能表现为“能连上但不能用”。

对比项

  • status:偏总览
  • health:偏运行健康
  • gateway status:偏服务与 RPC 探测
  • logs:偏排错细节
  • doctor:偏自动诊断与修复建议