Appearance
macOS 上的 Gateway 生命周期
macOS 应用默认通过 launchd 管理 Gateway,不将 Gateway 作为子进程启动。它首先尝试附加到配置端口上已运行的 Gateway;如果不可达,则通过外部 openclaw CLI 启用 launchd 服务(无内嵌运行时)。这带来了可靠的登录自启动和崩溃自动重启。
子进程模式(由应用直接启动 Gateway)目前不启用。如果需要与 UI 更紧密的耦合,在终端中手动运行 Gateway。
默认行为(launchd)
- 应用安装标签为
ai.openclaw.gateway的每用户 LaunchAgent (使用--profile/OPENCLAW_PROFILE时为ai.openclaw.<profile>;旧版com.openclaw.*受支持)。 - 启用本地模式时,应用确保 LaunchAgent 已加载并在需要时启动 Gateway。
- 日志写入 launchd Gateway 日志路径(在 Debug Settings 中可见)。
常用命令:
bash
launchctl kickstart -k gui/$UID/ai.openclaw.gateway
launchctl bootout gui/$UID/ai.openclaw.gateway运行命名 profile 时,将标签替换为 ai.openclaw.<profile>。
未签名开发构建
scripts/restart-mac.sh --no-sign 用于没有签名密钥时的快速本地构建。为防止 launchd 指向未签名的中继二进制文件,它会:
- 写入
~/.openclaw/disable-launchagent。
带签名运行 scripts/restart-mac.sh 时,如果存在该标记文件则会清除它。手动重置:
bash
rm ~/.openclaw/disable-launchagent仅附加模式
要强制 macOS 应用永不安装或管理 launchd,使用 --attach-only(或 --no-launchd)启动。这会设置 ~/.openclaw/disable-launchagent,应用只会附加到已运行的 Gateway。你也可以在 Debug Settings 中切换相同行为。
远程模式
远程模式不会启动本地 Gateway。应用通过 SSH 隧道连接到远程主机并经由隧道连接。
为什么选择 launchd
- 登录时自动启动。
- 内置重启/KeepAlive 语义。
- 可预期的日志和监控。
用 launchd 管理"我的龙虾",开机即在线,崩溃自重启——比手动跑终端靠谱多了。
如果将来确实需要真正的子进程模式,应将其作为独立的、明确的开发专用模式单独记录。