多网关

多个 Gateway(同一主机)

多数设置使用一个 Gateway,因为一个 Gateway 可以处理多个消息连接和 Agent。如果你需要更强的隔离或冗余(例如救援 bot),可以运行多个隔离的 Gateway(独立 profile/端口)。

隔离检查清单(必需)

如果共享这些,会引发配置竞争和端口冲突。

推荐:profiles(--profile

profiles 会自动作用于 OPENCLAW_STATE_DIR + OPENCLAW_CONFIG_PATH,并给服务名加后缀。

# main
openclaw --profile main setup # 中文注释:创建 main profile
openclaw --profile main gateway --port 18789

# rescue
openclaw --profile rescue setup # 中文注释:创建 rescue profile
openclaw --profile rescue gateway --port 19001

每个 profile 的服务:

openclaw --profile main gateway install
openclaw --profile rescue gateway install

救援 Bot 指南

在同一主机上运行第二个 Gateway,分别使用:

这样救援 bot 与主 bot 隔离,当主 bot 出问题时可用于调试或应用配置更改。

端口间隔:基础端口至少相隔 20 个端口,确保派生的浏览器/canvas/CDP 端口不冲突。

如何安装(救援 bot)

# 主 bot(已存在或新建,不带 --profile 参数)
# 运行在 18789 + Chrome CDC/Canvas/... 端口
openclaw onboard
openclaw gateway install

# 救援 bot(隔离 profile + 端口)
openclaw --profile rescue onboard
# 说明:
# - workspace 名称默认会加上 -rescue
# - 端口至少比 18789 大 20,最好直接选不同的基础端口,如 19789
# - 其余引导过程与正常相同

# 安装服务(如果引导未自动安装)
openclaw --profile rescue gateway install

端口映射(派生)

基础端口 = gateway.port(或 OPENCLAW_GATEWAY_PORT / --port)。

如果你在配置或环境中覆盖了这些,需要确保每个实例唯一。

浏览器/CDP 注意事项(常见坑)

手动环境示例

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 19001

快速检查

openclaw --profile main status
openclaw --profile rescue status
openclaw --profile rescue browser status