← 返回
未分类 中文

OpenClaw Doctor (macOS)

macOS Gateway 24/7 watchdog with 4-layer health checks and auto-repair. Monitors: L1 process alive, L2 HTTP port, L3 WebSocket communication (1006 detection)...
macOS网关7x24小时守护进程,具备四层健康检查与自动修复功能。监控项包括:L1进程存活、L2 HTTP端口、L3 WebSocket通信(含1006检测)...
dr-xiaoming
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 551
下载
💾 4
安装
1
版本
#latest

概述

OpenClaw Doctor — macOS Gateway 看门狗 v2

24/7 health watchdog for OpenClaw Gateway on macOS. Detects and auto-repairs four layers of failure.

Why

OpenClaw Gateway is the message bridge — if it dies, the AI assistant goes silent. Common failure modes on macOS:

LayerFailureSymptom
-------------------------
L1Process crashComplete silence
L2HTTP port stuckComplete silence
L3WebSocket 1006 disconnectProcess alive, HTTP OK, but messages don't arrive (sneakiest!)
L4Mac sleep/hibernateAll connections die after lid close or idle timeout

Architecture

LaunchAgent (every 5 min)
  → L1: pgrep + launchctl (process alive?)
  → L2: curl HTTP probe (port responding?)
  → L3: Log scan for WS 1006 errors (communication healthy?)
  → L4: caffeinate keepalive (prevent sleep)
  → Auto-repair with minimum intervention principle

Repair Strategy (escalating)

FailureActionRationale
----------------------------
Process downopenclaw doctor --repair → restart GatewayProcess crashed
HTTP unreachableRestart GatewayPort stuck
WS frequent disconnectRestart Node first → then full restartWS layer issue, Node restart usually sufficient
Post-sleep recoveryGateway + Node dual restartAll connections need rebuild

Setup

1. Copy the script

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

2. Configure (optional)

Environment variables for customization:

# In ~/.bashrc or ~/.zshrc (if non-default)
export OPENCLAW_DOCTOR_GATEWAY_URL="http://127.0.0.1:18789"  # default
export OPENCLAW_DOCTOR_SERVICE_NAME="ai.openclaw.gateway"     # default
export OPENCLAW_DOCTOR_NODE_SERVICE="ai.openclaw.node"        # default

3. Install LaunchAgent

Edit references/ai.openclaw.doctor.plist — replace REPLACE_WITH_HOME with your actual home directory path (e.g. /Users/yourname).

# Copy and customize the plist
cp references/ai.openclaw.doctor.plist ~/Library/LaunchAgents/ai.openclaw.doctor.plist
sed -i '' "s|REPLACE_WITH_HOME|$HOME|g" ~/Library/LaunchAgents/ai.openclaw.doctor.plist

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

4. Verify

# Manual test run
bash ~/.openclaw/doctor.sh

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

# Confirm caffeinate is running
pgrep -la caffeinate

# Confirm LaunchAgent is loaded
launchctl list | grep doctor

Logs

Location: ~/.openclaw/logs/doctor.log

PrefixMeaning
-----------------
HEARTBEATPeriodic health confirmation (hourly)
ALERTAnomaly detected
DIAGNOSISFault classification
ACTIONRepair in progress
RESOLVEDFault repaired
CRITICALAll repair attempts failed
INFOGeneral info (e.g. caffeinate started)

Auto-rotates at 5MB (keeps last 1000 lines).

Troubleshooting

Process alive + HTTP OK but messages don't arrive?

→ WS disconnect. Check: grep "1006" /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | tail -10

Disconnects every night?

→ Mac sleep. Verify caffeinate: pgrep -la caffeinate

Doctor itself not running?

→ Check LaunchAgent: launchctl list | grep doctor. Reload if missing.

Temporarily disable:

launchctl bootout gui/$(id -u)/ai.openclaw.doctor

Files

  • scripts/doctor.sh — Main watchdog script
  • references/ai.openclaw.doctor.plist — LaunchAgent template

Version History

VersionDateChanges
------------------------
v12026-03-07Initial: process check + HTTP probe + Gateway restart
v22026-03-23WS health check + Mac sleep prevention + layered repair + Node restart

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 23:31 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ADB Android Control

dr-xiaoming
通过ADB(Android调试桥)在Mac上远程控制Android设备,支持点击、滑动、输入文字、截图、录屏等操作。
★ 0 📥 853

Catl Harness Pr

dr-xiaoming
向 CATL Harness GitHub 仓库提交结构化的知识工程 pull request,遵循分支、提交、PR 及敏感内容规则。
★ 0 📥 599

小宿智能搜索

dr-xiaoming
Web search via 小宿智能搜索 V2 API (XiaoSu Smart Search). Use when internet search, web lookup, real-time information retrieva
★ 0 📥 468