Gateway Restart Helper 🔄
解决 OpenClaw Gateway 重启后 agent 失联的痛点。
问题
Gateway 重启会断开 WebSocket 连接,导致:
- Agent 收不到消息
- 需要用户手动发消息才能"复活"
- 体验不好
解决方案
使用 systemd-run 独立运行重启脚本,重启后自动发送唤醒事件,让 agent 自动恢复。
使用方法
重启 Gateway
在对话中告诉 agent:
- "重启"
- "重启 Gateway"
或者直接执行脚本:
systemd-run --user --unit=openclaw-restart-$(date +%s) --remain-after-exit ./restart_gateway.sh
Agent 自动操作
Agent 收到"重启"指令后,应该:
- 执行重启脚本(使用 systemd-run 确保独立运行)
- 脚本会自动:
- 记录重启时间
- 重启 Gateway
- 等待 20 秒启动完成
- 发送唤醒事件
- Agent 自动恢复,向用户问好
脚本说明
restart_gateway.sh 的关键点:
- 使用
systemd-run独立运行,不被 Gateway 重启影响 - 用 node 完整路径执行 openclaw(systemd-run 环境中 PATH 不生效)
- 等待 20 秒确保 Gateway 完全启动
- 记录详细日志到
/tmp/openclaw/restart.log
注意事项
- 需要 OpenClaw Gateway 使用 systemd 管理
- 需要根据实际的 node 和 openclaw 路径修改脚本
- 日志文件在
/tmp/openclaw/restart.log
License
MIT
