Gateway Keeper
OS-level watchdog for OpenClaw gateway. Runs outside the gateway process so it survives crashes.
How It Works
- 1. Health check — Runs
openclaw gateway status every 15 minutes - Auto-restart — If gateway is down, runs INLINECODE1
- Recovery signal — Writes
logs/gateway-recovery.json with crash timestamp - Session recovery — HEARTBEAT.md template detects recovery file, prompts agent to check incomplete work
Quick Setup
Install
Run the appropriate install script for your OS:
Windows (PowerShell as Admin):
CODEBLOCK0
Linux/macOS:
CODEBLOCK1
Uninstall
Windows:
CODEBLOCK2
Linux/macOS:
CODEBLOCK3
Recovery Protocol
After gateway restart, the agent should check logs/gateway-recovery.json:
CODEBLOCK4
Add to HEARTBEAT.md (done automatically by install script):
CODEBLOCK5
Files
| File | Purpose |
|---|
| INLINECODE4 | Windows health check + restart |
| INLINECODE5 |
Linux/macOS health check + restart |
|
scripts/install.ps1 | Windows Task Scheduler setup |
|
scripts/install.sh | Linux/macOS cron/systemd setup |
|
scripts/uninstall.ps1 | Windows cleanup |
|
scripts/uninstall.sh | Linux/macOS cleanup |
Customization
Edit check interval by modifying the scheduled task/cron entry. Default: 15 minutes.
To change recovery behavior, edit the HEARTBEAT.md recovery section.
网关守护者
OpenClaw网关的操作系统级看门狗。运行在网关进程外部,因此能在崩溃后继续存活。
工作原理
- 1. 健康检查 — 每15分钟运行一次 openclaw gateway status
- 自动重启 — 如果网关宕机,运行 openclaw gateway start
- 恢复信号 — 写入包含崩溃时间戳的 logs/gateway-recovery.json
- 会话恢复 — HEARTBEAT.md模板检测恢复文件,提示代理检查未完成的工作
快速设置
安装
运行适用于您操作系统的安装脚本:
Windows(以管理员身份运行PowerShell):
powershell
powershell -ExecutionPolicy Bypass -File /scripts/install.ps1
Linux/macOS:
bash
bash /scripts/install.sh
卸载
Windows:
powershell
powershell -ExecutionPolicy Bypass -File /scripts/uninstall.ps1
Linux/macOS:
bash
bash /scripts/uninstall.sh
恢复协议
网关重启后,代理应检查 logs/gateway-recovery.json:
json
{
crashed_at: 2026-02-26T00:00:00Z,
restarted_at: 2026-02-26T00:15:00Z,
restarted_by: gateway-keeper
}
添加到HEARTBEAT.md(由安装脚本自动完成):
markdown
网关崩溃恢复
如果 logs/gateway-recovery.json 存在:
- 1. 读取崩溃时间戳
- 列出所有活跃会话/子代理
- 检查每个会话是否有未完成的工作
- 根据需要恢复或重试
- 完成后删除恢复文件
文件
| 文件 | 用途 |
|---|
| scripts/check-gateway.ps1 | Windows健康检查+重启 |
| scripts/check-gateway.sh |
Linux/macOS健康检查+重启 |
| scripts/install.ps1 | Windows任务计划程序设置 |
| scripts/install.sh | Linux/macOS cron/systemd设置 |
| scripts/uninstall.ps1 | Windows清理 |
| scripts/uninstall.sh | Linux/macOS清理 |
自定义
通过修改计划任务/cron条目来编辑检查间隔。默认:15分钟。
要更改恢复行为,请编辑HEARTBEAT.md的恢复部分。