Skip to main content

多重 Gateways (同一主機)

大多數設定應使用單一 Gateway,因為單一 Gateway 即可處理多個訊息連線與 Agents。若您需要更強的隔離或冗餘 (例如:救援機器人 Rescue Bot),請使用隔離的 Profiles/Ports 運行分開的 Gateways。

隔離檢查清單 (必要)

  • OPENCLAW_CONFIG_PATH — Per-instance 設定檔
  • OPENCLAW_STATE_DIR — Per-instance Sessions, Creds, Caches
  • agents.defaults.workspace — Per-instance Workspace Root
  • gateway.port (或 --port) — 每個 Instance 唯一
  • 推導的 Ports (Browser/Canvas) 絕不可重疊
若這些共用,您會遇到 Config Races 與 Port Conflicts。

推薦: Profiles (--profile)

Profiles 自動界定 (Scope) OPENCLAW_STATE_DIR + OPENCLAW_CONFIG_PATH 並為服務名稱加上後綴。
Per-profile 服務:

Rescue-bot 指南

在同一台主機上運行第二個 Gateway,擁有其自己的:
  • Profile/Config
  • State Dir
  • Workspace
  • Base Port (加上 Derived Ports)
這讓 Rescue Bot 與 Main Bot 隔離,因此若 Primary Bot 當機,它可以用於除錯或套用 Config 變更。 Port 間距 (Spacing): 在 Base Ports 之間至少保留 20 個 Ports,以免推導出的 Browser/Canvas/CDP Ports 發生衝突。

如何安裝 (Rescue Bot)

Port Mapping (Derived)

Base Port = gateway.port (或 OPENCLAW_GATEWAY_PORT / --port)。
  • 瀏覽器控制服務連接埠 = Base + 2 (僅限 Loopback)
  • canvasHost.port = base + 4
  • Browser Profile CDP Ports 自動從 browser.controlPort + 9 .. + 108 分配
若您在 Config 或 Env 中覆蓋其中任何一個,必須保持每個 Instance 唯一。

Browser/CDP 註記 (常見陷阱)

  • 不要 在多個 Instances 上將 browser.cdpUrl 固定為相同數值。
  • 每個 Instance 需要其自己的 Browser Control Port 與 CDP Range (從其 Gateway Port 推導)。
  • 若您需要顯式 CDP Ports,請每個 Instance 設定 browser.profiles.<name>.cdpPort
  • Remote Chrome: 使用 browser.profiles.<name>.cdpUrl (Per profile, per instance)。

手動 Env 範例

快速檢查