Skip to content

[macOS] launchd 快速重启被误判为崩溃循环导致服务被卸载 #19138

@forvendettaw

Description

@forvendettaw

问题描述

在 macOS 上使用 launchd 部署 OpenClaw Gateway 时,如果服务每 5-10 分钟自动退出,launchd 会误判为崩溃循环(crash loop),并在连续 4 次快速退出后自动卸载服务。

环境

  • macOS
  • OpenClaw 版本:2026.2.15
  • 部署方式:launchd (LaunchAgent)

复现步骤

  1. 使用 openclaw gateway start 启动服务
  2. 服务配置了 KeepAlive: true
  3. 服务因为某种原因每 5-10 分钟退出一次
  4. 观察 launchd 状态:服务已被卸载

期望行为

launchd 应该正确区分"正常退出后重启"和"崩溃循环",不应该因为正常退出而卸载服务。

建议的修复方案

在生成的 LaunchAgent plist 文件中添加以下键:

  • ThrottleInterval (建议值: 60):服务退出后等待秒数才允许重启
  • StartInterval (建议值: 60):定期检查重启间隔
  • ExitTimeOut (建议值: 60):等待服务优雅退出的时间

示例:

<key>ThrottleInterval</key>
<integer>60</integer>
<key>StartInterval</key>
<integer>60</integer>
<key>ExitTimeOut</key>
<integer>60</integer>

这样即使服务频繁退出,只要退出间隔大于 ThrottleInterval,就不会被误判为崩溃循环。

临时解决方案

手动编辑 plist 文件添加上述参数,但每次运行 openclaw gateway start 会被覆盖。

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions