零停机升级 OpenClaw:查 release notes → 主公确认 → 旁路备份 → npm install → 重启 + 回滚兜底
Coding
Self Upgrade Gateway
Try it零停机升级 OpenClaw Gateway:查 release notes → 主公确认 → 旁路备份 → npm install → node版本自动检测 → 重启 + 回滚兜底
What it does
零停机升级 OpenClaw Gateway:查 release notes → 主公确认 → 旁路备份 → npm install → node版本自动检测 → 重启 + 回滚兜底
The skill document
self-upgrade-openclaw
用途
零停机升级 OpenClaw。
核心策略
查 release notes → 主公确认无 breaking change →
旁路备份(安全锚点)→ npm install -g →
修正 systemd Node 路径 → 更新 systemd 版本号 → 重启 + 健康检查 →
失败则从备份回滚 / 成功则自动清理
环境要求
| 项目 | 说明 |
|---|---|
| 操作系统 | Linux(WSL2 亦可) |
| Node.js | 至少一个版本满足新版 openclaw 的 engines.node 要求 |
| npm | 任意 |
| service 管理 | systemd user 模式 |
| 磁盘空间 | 至少 2G 可用 |
| 网络 | 能访问 registry.npmjs.org 和 api.github.com |
前提假设
- OpenClaw 通过
npm install -g全局安装 - 服务通过 systemd user 管理(
openclaw-gateway.service) - npm global 在
$HOME/.npm-global/ - 有
systemctl --user权限
流程
阶段 0: 获取当前状态 + Node 版本兼容性预检
- 读取 systemd 单元文件和 npm 全局目录,获取当前版本
- 查询 npm registry 获取最新稳定版版本号
- 如果最新版 ≤ 当前版,告知主公已是最新版,结束
- Node 兼容性预检:用
npm pack下载目标版本 → 读取engines.node要求 → 遍历which -a node及常见 Node 安装路径 → 如果没有一个 Node 版本满足要求则提示升级 Node 后重试
阶段 1: 获取 release notes,主公确认
- 从 GitHub API 获取目标版本的 release notes
- 展示给主公:当前版本 → 目标版本、Node 版本兼容性检查结果、release notes 核心摘要、是否包含 breaking changes
- 询问主公是否现在升级
阶段 2: 执行升级
运行升级脚本,全自主执行:
- 前置检查(命令可用性、磁盘空间、服务状态)
- Node 版本兼容性预检(预下载包、读 engines、扫描兼容 Node)
- 查 release notes(备忘)
- 旁路备份
- npm install -g openclaw@latest(失败自动回滚)
- 修正 systemd ExecStart 中的 Node 路径(如果旧 Node 不满足新版本要求)
- 更新 systemd 版本号
- 重启 + 健康检查(60s 超时)
- 失败回滚 / 成功清理
阶段 3: 汇报结果
安全机制
| 机制 | 说明 |
|---|---|
| Node 兼容性预检 | 预下载包 → 解析 engines.node → 检查系统所有 Node → 无兼容版本则中止 |
| systemd Node 路径自动修正 | 检测 ExecStart 中的 node 路径,不满足要求时自动切换到兼容版本 |
| 旁路备份 + 自动回滚 | 健康检查失败后恢复旧代码 + 旧 Node 路径 + 重启旧版 |
| 全日志落盘 | 不依赖终端 |
| 人工确认 | 先展示 release notes 再执行 |
变更日志
v2.0.0
- 新增 Node 版本兼容性预检
- 新增自动修正 systemd ExecStart 路径
- 兼容两种版本号格式
- 修复 release notes 查询硬编码版本号的 bug
v1.0.0
- 初始版本
Related skills
Use when upgrading OpenClaw or recovering from partial updates, gateway failures, migrations, service drift, channel failures, or version mismatch.
OpenClaw gateway 重启标准流程:五道校验门(Gate0-4)+自杀进程规避+continuationMessage回执,通用
Protect long-running OpenClaw gateways from unsafe restarts with preflight checks, watchdog diagnosis, and evidence capture.
Use when updating OpenClaw or debugging an OpenClaw instance after an update. This skill acts as a structured update runbook with emphasis on gateway startup...
Route OpenClaw CLI requests to the right command family and profile, then verify the outcome.