返回顶部
g

gateway-health-monitor网关健康监控

Monitor and auto-fix OpenClaw gateway stability issues. Diagnoses launchd throttling, plugin restart loops, hung shutdowns, and macOS power management interference. Use when the gateway keeps disconnecting, restarting, or staying down for long periods. Triggers on "gateway down", "gateway keeps restarting", "disconnected", "gateway unstable", "launchd throttling", "gateway won't start".

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
86
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

gateway-health-monitor

网关健康监控

诊断并修复macOS上OpenClaw网关的稳定性问题。涵盖导致长时间停机的常见故障模式。

快速诊断

运行诊断脚本:

bash
bash scripts/diagnose.sh

该脚本检查:进程状态、launchd分类、重启次数、plist配置、电源管理以及插件解析循环。

常见故障模式

1. 插件重启循环(最常见)

症状:网关每5-7分钟重启一次。日志显示restartReason=config.patch,附带plugins.installs.*.resolvedAt。

原因:插件在每次启动时重新解析→向openclaw.json写入新时间戳→配置监视器检测到变更→触发延迟重启→SIGTERM→循环重复。

修复:将gateway.reload.mode设置为hot:

bash
openclaw config set gateway.reload.mode hot

在hot模式下,安全变更会立即热应用。关键变更(如插件时间戳)仅记录警告——不会自动重启。这打破了循环。

验证:grep reload ~/.openclaw/logs/gateway.log | tail -5应显示config change applied (dynamic reads)而非restart。

2. macOS节流(低效分类)

症状:网关宕机并持续30-60分钟以上。launchctl print显示immediate reason = inefficient。

原因:多次重启后(每天10次以上),macOS将该任务标记为低优先级,并通过App Nap / Power Nap逻辑延迟重启。

修复:在launchd plist(~/Library/LaunchAgents/ai.openclaw.gateway.plist)中添加以下键:

xml
ProcessType
Interactive
LowPriorityBackgroundIO

然后重新加载:

bash
launchctl bootout gui/$(id -u)/ai.openclaw.gateway
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/ai.openclaw.gateway.plist

注意:openclaw gateway start会覆盖plist。使用下面的修补脚本自动重新应用。

3. 挂起关闭

症状:网关收到SIGTERM但未退出。launchd因旧PID仍存活而无法重启。

修复:在plist中设置ExitTimeOut:

xml
ExitTimeOut
10

10秒后,launchd发送SIGKILL。

4. Power Nap干扰

症状:网关在Mac睡眠/唤醒周期中宕机。

检查:pmset -g | grep powernap

修复:sudo pmset -a powernap 0

Plist自动修补器

由于openclaw gateway start会覆盖plist,使用scripts/patch-plist.sh作为launchd WatchPaths代理:

bash

安装修补器


bash scripts/install-patcher.sh

这将创建一个launchd代理,监视网关plist,并在任何覆盖发生后几秒内重新添加ExitTimeOut、ProcessType和LowPriorityBackgroundIO。

监控

单行健康检查

bash
bash scripts/health-check.sh

健康时返回退出码0,检测到问题时返回1。适用于cron或心跳集成。

持续监控(cron集成)

添加到您的OpenClaw cron:

检查网关健康:bash ~/path/to/scripts/health-check.sh && echo 网关健康 || echo 警报:检测到网关问题

推荐配置

为在macOS上获得最大稳定性:

json5
{
gateway: {
reload: { mode: hot },
},
}

加上plist键:ExitTimeOut=10、ProcessType=Interactive、LowPriorityBackgroundIO=false、ThrottleInterval=1、KeepAlive=true。

故障排除参考

症状检查修复
每5-7分钟重启grep restartReason gateway.logreload.mode = hot
宕机30-60分钟以上
launchctl print → inefficient | ProcessType=Interactive | | SIGTERM后不退出 | ps -p PID after SIGTERM | ExitTimeOut=10 | | 睡眠后宕机 | pmset -g \| grep powernap | pmset -a powernap 0 | | 插件时间戳变化 | grep resolvedAt openclaw.json | reload.mode = hot |

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 gateway-health-monitor-1775928678 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 gateway-health-monitor-1775928678 技能

通过命令行安装

skillhub install gateway-health-monitor-1775928678

下载

⬇ 下载 gateway-health-monitor v1.0.0(免费)

文件大小: 6.63 KB | 发布时间: 2026-4-12 10:04

v1.0.0 最新 2026-4-12 10:04
Initial release: diagnose and fix OpenClaw gateway stability issues on macOS (launchd throttling, plugin restart loops, hung shutdowns, power management)

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部