OpenClawSkills
GitHub
平台 • 5 分钟阅读

Gateway 生命周期

macOS 上的 Gateway 生命周期(launchd)

macOS 应用默认通过 launchd 管理 Gateway,不会作为

子进程启动 Gateway。它首先尝试附加到已运行的

配置端口上的 Gateway;如果无法访问,则通过外部

''openclaw'' CLI 启用 launchd 服务(无嵌入式运行时)。这为您提供

可靠的登录时自动启动和崩溃时重启。

子进程模式(应用直接启动的 Gateway)目前不使用。

如果您需要与 UI 更紧密的耦合,请在终端中手动运行 Gateway。

Tutorial.step

默认行为(launchd)

- 应用安装一个标记为 ''bot.molt.gateway'' 的每用户 LaunchAgent

(or ''bot.molt.<profile>'' when using ''--profile''/''OPENCLAW_PROFILE''; legacy ''com.openclaw.*'' is supported).

- 启用本地模式时,应用确保 LaunchAgent 已加载并在

需要时启动 Gateway。

- 日志写入到 launchd gateway 日志路径(在调试设置中可见)。

常用命令:

运行命名配置文件时,将标签替换为 ''bot.molt.<profile>''。

Bash
launchctl kickstart -k gui/$UID/bot.molt.gateway
launchctl bootout gui/$UID/bot.molt.gateway

PlatformsMacChildprocessPage step 01: P8

Tutorial.step

未签名的开发构建

''scripts/restart-mac.sh --no-sign'' 用于快速本地构建,当您没有

签名密钥时。为了防止 launchd 指向未签名的中继二进制文件,它会:

- 写入 ''~/.openclaw/disable-launchagent''。

''scripts/restart-mac.sh'' 的签名运行会在标记存在时

清除此覆盖。要手动重置:

Bash
rm ~/.openclaw/disable-launchagent
Tutorial.step

仅附加模式

要强制 macOS 应用从不安装或管理 launchd,请使用

''--attach-only''(或 ''--no-launchd'')启动它。这会设置 ''~/.openclaw/disable-launchagent'',

因此应用仅附加到已运行的 Gateway。您可以在调试设置中切换

相同的行为。

Tutorial.step

远程模式

远程模式从不启动本地 Gateway。应用使用 SSH 隧道连接到

远程主机并通过该隧道连接。

Tutorial.step

为什么我们更喜欢 launchd

- 登录时自动启动。

- 内置重启/KeepAlive 语义。

- 可预测的日志和监督。

如果再次需要真正的子进程模式,应将其记录为

单独的、明确的仅开发模式。