跳到內容

使用 OpenClaw Daemon 管理 Gateway 服務指令指南

管理背景服務總是開發者最頭痛的事情之一。不管是 Linux 的 systemd 還是 macOS 的 launchd,手動撰寫設定檔並追蹤服務狀態既瑣碎又容易出錯,尤其是當你只想快速讓 Gateway 跑起來的時候。

這是 Gateway 服務管理指令的舊版別名(Legacy alias)。

openclaw daemon ... 指令所對應的服務控制功能,與 openclaw gateway ... 服務指令完全相同。

Terminal window
openclaw daemon status
openclaw daemon install
openclaw daemon start
openclaw daemon stop
openclaw daemon restart
openclaw daemon uninstall
  • status: 顯示服務安裝狀態並探測 Gateway 健康狀況
  • install: 安裝服務 (launchd/systemd/schtasks)
  • uninstall: 移除服務
  • start: 啟動服務
  • stop: 停止服務
  • restart: 重啟服務
  • status: --url, --token, --password, --timeout, --no-probe, --require-rpc, --deep, --json
  • install: --port, --runtime <node|bun>, --token, --force, --json
  • 生命週期 (uninstall|start|stop|restart): --json

備註:

  • status 會在可能的情況下,解析已設定的驗證 SecretRefs 來進行探測驗證。
  • 如果在此指令路徑中未解析必要的驗證 SecretRef,當探測連線或驗證失敗時,daemon status --json 會回報 rpc.authWarning;請明確傳遞 --token/--password 或先解析 secret 來源。
  • 如果探測成功,系統會隱藏未解析的 auth-ref 警告,以避免誤報。
  • 在 Linux systemd 安裝中,status 的 token 偏移(drift)檢查包含 Environment= 和 EnvironmentFile= 單位來源。
  • 偏移檢查會使用合併的 runtime 環境(優先使用服務指令環境,接著是程序環境備援)來解析 gateway.auth.token SecretRefs。
  • 如果 token 驗證未實際啟用(例如明確將 gateway.auth.mode 設定為 password/none/trusted-proxy,或是未設定模式且 password 優先且沒有 token 候選者),token 偏移檢查會跳過設定 token 解析。
  • 當 token 驗證需要 token 且 gateway.auth.token 是由 SecretRef 管理時,install 會驗證 SecretRef 是否可解析,但不會將解析後的 token 持久化到服務環境元數據(metadata)中。
  • 如果 token 驗證需要 token 且設定的 token SecretRef 未解析,安裝將會失敗並關閉。
  • 如果同時設定了 gateway.auth.token 和 gateway.auth.password 且未設定 gateway.auth.mode,安裝將被阻斷,直到你明確設定模式為止。

請使用 openclaw gateway 查看目前的文檔與範例。


如果你在設定服務時遇到困難,可以詢問我們的 AI Setup Assistant。

OpenClaw

OpenClaw Expert

還是卡住了?

如果這篇文件沒有解決你的情境,直接問 OpenClaw Expert,拿到可執行步驟。