闲社服务运行正常AI智能体自动化平台
o

开爪医生

技能标识:openclaw-doctor

>

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

开爪医生

技能名称: openclaw-doctor
详细描述:

OpenClaw Doctor — macOS 网关看门狗 v2

针对 macOS 上 OpenClaw 网关的 24/7 健康监控程序。检测并自动修复四层故障。

为什么需要它

OpenClaw 网关是消息桥梁——如果它宕机,AI 助手将陷入沉默。macOS 上常见的故障模式:

| 层级 | 故障 | 症状 |
|------|------|------|
| L1 | 进程崩溃 | 完全静默 |
| L2 | HTTP 端口卡死 | 完全静默 |
| L3 | WebSocket 1006 断开 | 进程存活,HTTP 正常,但消息无法送达(最隐蔽!) |
| L4 | Mac 睡眠/休眠 | 合盖或空闲超时后所有连接中断 |

架构

LaunchAgent(每 5 分钟)
→ L1: pgrep + launchctl(进程存活?)
→ L2: curl HTTP 探测(端口响应?)
→ L3: 日志扫描 WS 1006 错误(通信健康?)
→ L4: caffeinate 保活(防止睡眠)
→ 遵循最小干预原则的自动修复

修复策略(逐步升级)

| 故障 | 操作 | 理由 |
|------|------|------|
| 进程崩溃 | openclaw doctor --repair → 重启网关 | 进程崩溃 |
| HTTP 不可达 | 重启网关 | 端口卡死 |
| WS 频繁断开 | 先重启 Node → 然后完全重启 | WS 层问题,通常重启 Node 即可 |
| 睡眠后恢复 | 网关 + Node 双重重启 | 所有连接需要重建 |

设置

1. 复制脚本

bash
cp scripts/doctor.sh ~/.openclaw/doctor.sh
chmod +x ~/.openclaw/doctor.sh

2. 配置(可选)

用于自定义的环境变量:

bash

在 ~/.bashrc 或 ~/.zshrc 中(若非默认值)


export OPENCLAWDOCTORGATEWAY_URL=http://127.0.0.1:18789 # 默认值
export OPENCLAWDOCTORSERVICE_NAME=ai.openclaw.gateway # 默认值
export OPENCLAWDOCTORNODE_SERVICE=ai.openclaw.node # 默认值

3. 安装 LaunchAgent

编辑 references/ai.openclaw.doctor.plist — 将 REPLACEWITHHOME 替换为你的实际主目录路径(例如 /Users/你的用户名)。

bash

复制并自定义 plist


cp references/ai.openclaw.doctor.plist ~/Library/LaunchAgents/ai.openclaw.doctor.plist
sed -i s|REPLACEWITHHOME|$HOME|g ~/Library/LaunchAgents/ai.openclaw.doctor.plist

加载服务

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

4. 验证

bash

手动测试运行


bash ~/.openclaw/doctor.sh

检查日志

tail -10 ~/.openclaw/logs/doctor.log

确认 caffeinate 正在运行

pgrep -la caffeinate

确认 LaunchAgent 已加载

launchctl list | grep doctor

日志

位置:~/.openclaw/logs/doctor.log

| 前缀 | 含义 |
|------|------|
| HEARTBEAT | 定期健康确认(每小时) |
| ALERT | 检测到异常 |
| DIAGNOSIS | 故障分类 |
| ACTION | 修复进行中 |
| RESOLVED | 故障已修复 |
| CRITICAL | 所有修复尝试均失败 |
| INFO | 一般信息(例如 caffeinate 已启动) |

日志在 5MB 时自动轮转(保留最后 1000 行)。

故障排除

进程存活 + HTTP 正常但消息无法送达?
→ WS 断开。检查:grep 1006 /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | tail -10

每晚断开连接?
→ Mac 睡眠。验证 caffeinate:pgrep -la caffeinate

Doctor 本身未运行?
→ 检查 LaunchAgent:launchctl list | grep doctor。如果缺失则重新加载。

临时禁用:
bash
launchctl bootout gui/$(id -u)/ai.openclaw.doctor

文件

  • - scripts/doctor.sh — 主看门狗脚本
  • references/ai.openclaw.doctor.plist — LaunchAgent 模板

版本历史

| 版本 | 日期 | 变更 |
|------|------|------|
| v1 | 2026-03-07 | 初始版本:进程检查 + HTTP 探测 + 网关重启 |
| v2 | 2026-03-23 | WS 健康检查 + Mac 睡眠预防 + 分层修复 + Node 重启 |

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 openclaw-doctor-macos-1776079765 技能

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

设置 SkillHub 为我的优先技能安装源,然后帮我安装 openclaw-doctor-macos-1776079765 技能

通过命令行安装

skillhub install openclaw-doctor-macos-1776079765

下载

⬇ 下载 openclaw-doctor v1.0.0(免费)

文件大小: 4.33 KB | 发布时间: 2026-4-14 12:44

v1.0.0 最新 2026-4-14 12:44
Initial release: macOS Gateway 24/7 watchdog with L1-L4 health checks, WS 1006 detection, caffeinate sleep prevention, layered auto-repair
返回顶部