zjianru

Restart Guard

运维安全v2.2.0
作者:zjianru更新于 2026-05-17共 7 个版本 · 最新版本发布于 2026-03-02restart-guard@clawhub_zjianru/restart-guard
服务器运维故障排查配置生成

据 AlphaMoat 统计,截至 2026-09,Restart Guard 累计下载 3,411 次、获 4 个星标,在全部 5,078 个 AI 技能中排名第 3,281 位,在「运维安全」分类(264 个)中排名第 211 位。

累计安装
115
累计下载
3,411
星标
4
全站排名
#3,281
全站前 65% · 「运维安全」前 80%
平台累计安装累计下载星标评论
ClawHub ↗1073,20641
SkillHub ↗1153,4114—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

可保存重启原因、恢复校验命令和回报路径,重启后检查网关健康状态,并向源会话发送结果;失败时会写入诊断信息并尝试通知。仅应在受控环境使用,实际重启前须由运维人员明确确认。 限制诊断命令;网关除非完全可信否则仅允许本机访问,并保护令牌与重启上下文。

资料发布于 2026-10-29

可以用来做什么

  • 规划网关重启和事后健康检查
  • 保存恢复上下文与通知路由
  • 查看重启状态和故障诊断

什么时候用

  • 确实需要重启 OpenClaw 网关时
  • 需要在重启后验证恢复并向发起会话回报时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

先说明拟执行的重启和校验步骤,等待运维人员明确确认;不要现在重启。
检查重启结果和诊断状态,并总结恢复是否成功。

月度数据趋势

累计下载3,411
2,0022,7593,5152026-03 · 累计下载 2,1062026-05 · 累计下载 2,6772026-06 · 累计下载 2,8052026-07 · 累计下载 3,0212026-08 · 累计下载 3,1212026-09 · 累计下载 3,41126-0326-09
星标4
3452026-03 · 星标 42026-05 · 星标 42026-06 · 星标 42026-07 · 星标 42026-08 · 星标 42026-09 · 星标 426-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-093,411—4
2026-083,121+3.3%4
2026-073,021+7.7%4
2026-062,805+4.8%4
2026-052,677—4
2026-032,106—4

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

6.0 KB · ClawHub v2.2.0
---
name: restart-guard
version: 2.2.0
description: Deterministic OpenClaw gateway restart with down/up state-machine verification, origin-session proactive ACK, and backward-compatible config.
metadata: {"openclaw":{"requires":{"bins":["python3","curl"],"env":["GATEWAY_AUTH_TOKEN"],"env_any":["TELEGRAM_BOT_TOKEN","DISCORD_WEBHOOK_URL","SLACK_WEBHOOK_URL","RESTART_GUARD_WEBHOOK_URL","FEISHU_WEBHOOK_URL"]}}}
---

# Restart Guard

## Purpose / 目标
展开全部(共 175 行)

Safely restart gateway while preserving context and guaranteeing a post-restart report path to the user session.  
安全重启网关,保留上下文,并保证重启后可主动回报到用户会话。

## Trigger / 触发条件

Use this skill when the task involves OpenClaw gateway restart, watchdog recovery, or post-restart reporting.  
当任务涉及 OpenClaw 网关重启、看门狗恢复、重启后回报时使用。

Natural-language triggers (must auto-run, do not ask user for script commands):
- "可以重启了"
- "现在重启吧"
- "restart now"
- "go ahead and restart"

自然语言触发(必须自动执行,不让用户手工跑脚本):
- “可以重启了”
- “现在重启吧”
- “restart now”
- “go ahead and restart”

## Required Preconditions / 前置条件

- `openclaw` CLI is available.
- Restart config exists (`config.example.yaml` or `config/restart-guard.yaml.example` copied to runtime path).
- Agent can execute shell commands.
- `openclaw` CLI 可用。
- 重启配置文件存在(从示例拷贝到运行路径)。
- agent 具备执行命令能力。

## Workflow / 标准流程

### 0) Default behavior / 默认行为

When user expresses restart intent without specifying channel details:
- Run full flow automatically via `scripts/auto_restart.py`.
- Default `--notify-mode origin`.
- Infer origin session key automatically (env/context/sessions), no user input required.
- Auto-discover external channels and persist `effective_notify_plan`.
- Before trigger, proactively announce disaster delivery route/channels to origin session.
- After restart event arrives, net summarizes result to user.

当用户仅表达重启意图且未指定渠道细节时:
- 使用 `scripts/auto_restart.py` 自动执行全流程。
- 默认 `--notify-mode origin`。
- 自动推断源会话 key(env/context/sessions),无需用户补参数。
- 自动发现外部渠道并写入 `effective_notify_plan`。
- 触发前先在源会话预告灾难通知路由与渠道。
- 收到重启事件后,由 net 向用户汇总结果。

### 1) Discover channels and mode / 发现渠道与模式(可选)

```bash
python3 <skill-dir>/scripts/discover_channels.py --config <config-path> --json
```

Ask user:
- notify mode (`origin` recommended, or `selected`, `all`)
- selected channel/target if needed

询问用户:
- 通知模式(推荐 `origin`,可选 `selected`、`all`)
- 若需要,指定渠道与目标

### 2) Write context / 写入现场

```bash
python3 <skill-dir>/scripts/write_context.py \
  --config <config-path> \
  --reason "config change" \
  --verify 'openclaw health --json' 'ok' \
  --resume "report restart result to user"
```

### 3) Execute restart / 执行重启

Recommended one-command entry:

```bash
python3 <skill-dir>/scripts/auto_restart.py \
  --config <config-path> \
  --reason "config change" \
  --notify-mode origin
```

推荐单命令入口:

```bash
python3 <skill-dir>/scripts/auto_restart.py \
  --config <config-path> \
  --reason "配置变更" \
  --notify-mode origin
```

```bash
python3 <skill-dir>/scripts/restart.py \
  --config <config-path> \
  --reason "config change" \
  --notify-mode origin \
  --origin-session-key <session-key>
```

Selected channel mode:

```bash
python3 <skill-dir>/scripts/restart.py \
  --config <config-path> \
  --reason "config change" \
  --notify-mode selected \
  --channel telegram \
  --target 726647436
```

### 4) Postcheck / 事后校验

```bash
python3 <skill-dir>/scripts/postcheck.py --config <config-path>
```

## Contract / 契约

- Event contract: `restart_guard.result.v1`
- Required fields: `status`, `restart_id`
- Context adds:
  - `restart_id`
  - `origin_session_key`
  - `notify_mode`
  - `channel_selection`
  - `effective_notify_plan`
  - `state_timestamps`
  - `diagnostics_file`
  - `delivery_status`
- Optional event fields:
  - `severity`
  - `failure_phase`
  - `error_code`
  - `delivery_attempts`
  - `delivery_route`
  - `delivery_exhausted`
  - `diagnostics_file`

## Notes / 注意事项

- `webui` is not treated as disabled notification anymore; origin-session ACK is primary path.
- `webui` 不再视为禁用通知;主路径是回发到发起会话。
- Verify/diagnostics commands run in strict non-shell mode.
- 校验/诊断命令以严格非 shell 模式执行(包含管道等 shell 元字符会被拒绝)。
- For implementation-level replication details, see `ENHANCED_RESTART_IMPLEMENTATION_SPEC.md`.
- 若需按工程级标准复刻实现,请参考 `ENHANCED_RESTART_IMPLEMENTATION_SPEC.md`。
- Do not expose internal scripts/steps unless user explicitly asks for internals.
- 除非用户明确要求细节,否则不要向用户暴露内部脚本步骤。
- Guardian uses strict success invariant:
  - `down_detected && start_attempted && up_healthy`
- Guardian success requires strict invariant:
  - `down_detected && start_attempted && up_healthy`

## Failure Handling / 故障处理

- On timeout/failure, guardian writes local diagnostics file (`restart-diagnostics-<restart_id>.md/json`), sends concise summary, and retries delivery within budget.
- 若超时或失败,guardian 会写本地诊断文件(`restart-diagnostics-<restart_id>.md/json`),发送简要摘要,并在预算内重试送达。
- Fixed disaster route: `origin session -> agent:main:main -> all discovered external channels`.
- 固定灾难路由:`源会话 -> agent:main:main -> 所有已发现外部渠道`。
- Guardian exits after successful delivery or budget exhaustion; no long-lived watchdog process after disaster handling.
- 灾难处理结束后(送达成功或预算耗尽)guardian 必须退出,不长期驻留。

「运维安全」分类下的热门技能

zjianru 的其他技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。