360 Secure SkillHub
360 安全技能中心

Gateway Restart Helper

该 Skill 针对 OpenClaw Gateway 重启后 agent 失联的场景:用 systemd-run 独立运行脚本重启 Gateway,等待约 20 秒后发送唤醒事件使 agent 自动恢复,日志写入 /tmp/openclaw/restart.log。需要 Gateway 由 systemd 管理,并按实际环境调整 node 与 openclaw 路径。

tinysparkle
tinysparkle
热度 19.71
最近更新 2026-03-24 18:11:56
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / DevOps / 工作流

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add gateway-restart-helper
Metadata
name
gateway-restart-helper
description
OpenClaw Gateway 自动重启助手 - 重启后自动唤醒 agent,无需手动对话。
metadata
{"openclaw":{"requires":{"bins":["node","systemd-run"]}}}

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 收到"重启"指令后,应该:

  1. 执行重启脚本(使用 systemd-run 确保独立运行)
  2. 脚本会自动:
    • 记录重启时间
    • 重启 Gateway
    • 等待 20 秒启动完成
    • 发送唤醒事件
  3. 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