多個閘道
多個閘道(同一主機)
Section titled “多個閘道(同一主機)”大多數安裝應該使用一個閘道,因為單一閘道可以處理多個訊息連線和代理程式。如果您需要更強的隔離或冗餘(例如,救援機器人),請使用獨立的設定檔/連接埠執行分開的閘道。
隔離檢查清單(必需)
Section titled “隔離檢查清單(必需)”OPENCLAW_CONFIG_PATH— 每個執行個體的設定檔OPENCLAW_STATE_DIR— 每個執行個體的 session、creds、快取agents.defaults.workspace— 每個執行個體的工作區根目錄gateway.port(或--port) — 每個執行個體唯一- 衍生的連接埠(瀏覽器/canvas)不得重疊
如果共用這些項目,您將會遇到設定競爭和連接埠衝突。
建議:設定檔(--profile)
Section titled “建議:設定檔(--profile)”設定檔會自動限定 OPENCLAW_STATE_DIR + OPENCLAW_CONFIG_PATH 的範圍並加上服務名稱後綴。
# mainopenclaw --profile main setupopenclaw --profile main gateway --port 18789
# rescueopenclaw --profile rescue setupopenclaw --profile rescue gateway --port 19001每個設定檔的服務:
openclaw --profile main gateway installopenclaw --profile rescue gateway install救援機器人指南
Section titled “救援機器人指南”在同一主機上執行第二個閘道,並擁有自己的:
- 設定檔/設定
- 狀態目錄
- 工作區
- 基礎連接埠(加上衍生連接埠)
這能讓救援機器人與主機器人保持隔離,以便在主要機器人停機時進行偵錯或套用設定變更。
連接埠間距:基礎連接埠之間至少保留 20 個連接埠,以免衍生的瀏覽器/canvas/CDP 連接埠發生衝突。
如何安裝(救援機器人)
Section titled “如何安裝(救援機器人)”# Main bot (existing or fresh, without --profile param)# Runs on port 18789 + Chrome CDC/Canvas/... Portsopenclaw onboardopenclaw gateway install
# Rescue bot (isolated profile + ports)openclaw --profile rescue onboard# Notes:# - workspace name will be postfixed with -rescue per default# - Port should be at least 18789 + 20 Ports,# better choose completely different base port, like 19789,# - rest of the onboarding is the same as normal
# To install the service (if not happened automatically during setup)openclaw --profile rescue gateway install連接埠對應(衍生)
Section titled “連接埠對應(衍生)”基礎連接埠 = gateway.port(或 OPENCLAW_GATEWAY_PORT / --port)。
- 瀏覽器控制服務連接埠 = 基礎連接埠 + 2(僅限 loopback)
- Canvas 主機由閘道 HTTP 伺服器提供服務(與
gateway.port的連接埠相同) - 瀏覽器設定檔 CDP 連接埠從
browser.controlPort + 9 .. + 108自動分配
如果您在設定或環境變數中覆寫了這些項目中的任何一個,您必須確保每個執行個體都是唯一的。
瀏覽器/CDP 注意事項(常見陷阱)
Section titled “瀏覽器/CDP 注意事項(常見陷阱)”- 請勿將多個執行個體上的
browser.cdpUrl固定為相同的值。 - 每個執行個體都需要自己的瀏覽器控制連接埠和 CDP 範圍(由其閘道連接埠衍生)。
- 如果您需要明確的 CDP 連接埠,請為每個執行個體設定
browser.profiles.<name>.cdpPort。 - 遠端 Chrome:使用
browser.profiles.<name>.cdpUrl(每個設定檔、每個實例各一個)。
手動環境變數範例
Section titled “手動環境變數範例”OPENCLAW_CONFIG_PATH=~/.openclaw/main.json \OPENCLAW_STATE_DIR=~/.openclaw-main \openclaw gateway --port 18789
OPENCLAW_CONFIG_PATH=~/.openclaw/rescue.json \OPENCLAW_STATE_DIR=~/.openclaw-rescue \openclaw gateway --port 19001openclaw --profile main statusopenclaw --profile rescue statusopenclaw --profile rescue browser status