360 Secure SkillHub
360 安全技能中心

Gateway Self-Heal Watchdog

这是OpenClaw网关的自修复看门狗工具,核心提供三层防护:自动备份配置、进程死亡时重启网关、运行异常(如认证失效)时回滚至可用配置并重启。适用于网关容灾部署,应对进程崩溃、配置损坏等故障。通过setup脚本安装并注册为cron任务自动执行,支持手动查看状态、备份配置、查看日志或禁用,操作日志可追溯。

mupengi-bot
mupengi-bot
热度 70.89
最近更新 2026-05-17 13:33:40
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add gw-self-heal
Metadata
name
gateway-watchdog
description
Self-healing watchdog for OpenClaw gateway. Auto-backup openclaw.json before changes, health-check the gateway process, and auto-rollback to last known good config on failure. Use when setting up gateway resilience, self-recovery, auto-restart, config backup, or when the user mentions watchdog, self-heal, gateway down, or config recovery.

Gateway Watchdog

Automated self-healing system for OpenClaw gateway failures including config corruption, process crashes, and auth failures.

How It Works

Three-layer protection:

  1. Config Guard — Auto-backup openclaw.json on every successful health check
  2. Process Watchdog — Detect gateway process death → auto-restart
  3. Auth Health Check — Detect running-but-broken state → rollback config → restart

Setup

Run the setup script to install the watchdog:

bash scripts/setup-watchdog.sh

This will:

  • Create the watchdog script at ~/.openclaw/watchdog.sh
  • Register it as a cron job (every minute)
  • Take an initial config backup

Manual Commands

# Check watchdog status
bash scripts/watchdog-status.sh

# Force backup current config
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak

# View watchdog logs
cat ~/.openclaw/watchdog.log | tail -20

# Disable watchdog
crontab -l | grep -v watchdog | crontab -

Recovery Levels

Level Condition Action Auto?
1 Process dead, config OK Restart gateway ✅
2 Process alive, health check fail Rollback config + restart ✅
3 No valid backup exists Log alert, notify if possible ⚠️ Manual

Config Backup Strategy

  • Auto-backup: On every successful health check, current config overwrites .bak
  • Pre-change backup: Before any openclaw.json edit, copy to .bak.prev
  • Broken config preserved: Failed configs saved as .broken.<timestamp> for debugging

Logs

All watchdog activity logged to ~/.openclaw/watchdog.log with timestamps.

Platform Support

  • macOS: cron-based (launchd alternative in references/launchd.md)
  • Linux: cron or systemd (see references/systemd.md)
  • Docker: Use HEALTHCHECK directive (see references/docker.md)