升级源码 checkout
带关卡的 git pull 加重启:坏提交在一个临时进程里失败,而不是在你要用来修它的服务里失败。桌面和托管 release,包括 v0.6.6 到 v0.7.0:升级。
| 目标 | 命令 |
|---|---|
| 会有什么变化?只读 | openprogram upgrade status--json:head_sha、target_sha、update_available |
| 打印计划 | openprogram upgrade --dry-run |
| 执行 | openprogram upgrade |
步骤
| 步骤 | 做什么 | 失败代码 |
|---|---|---|
| 1 preflight | 拒绝脏工作区,解析目标,降级前询问 | dirty-worktree、downgrade-needs-confirmation |
| 2 checkout | 快进到目标 | checkout-failed |
| 3 deps | pyproject.toml 或 setup.py 变化时 pip install -e .;package-lock.json 变化时 npm ci | deps-failed |
| 4 build | 对应 workspace 或 package-lock.json 变化时重建 apps/web 或 apps/cli | build-failed |
| 5 probe | 在隔离 profile 和临时端口上启动新代码,等 /healthz,跑 doctor,然后杀掉 | probe-failed |
| 6 restart | 重启真实服务 | restart-failed |
| 7 verify | 轮询直到服务报告新提交 | verify-failed |
第 6 步之前运行中的服务不受影响。第一次失败即停止,打印代码并以非零退出。进度:~/.openprogram/upgrade-state.json。
某步失败时
| 代码 | 处理 |
|---|---|
dirty-worktree | 提交你的改动 |
downgrade-needs-confirmation | 目标更旧,旧代码可能读不懂新代码写的配置。确定的话加 --yes |
probe-failed | 新代码启动不了。没有重启;修复应在上游 |
verify-failed | 已重启,但服务没有报告新提交。没有自动回滚;运行打印的命令:git -C <repo> checkout <previous-sha> && openprogram restart |
参数
| 参数 | 效果 |
|---|---|
--dry-run | 只做计划;不改 checkout、worker 或升级状态。显式的 --channel 仍会持久化 |
--no-restart | 在 probe 后停止。checkout 已移动,服务保持旧代码直到你重启 |
--yes、-y | 允许降级 |
--channel NAME | 跟随另一条线并持久化为 update.channel。只内置 stable,这里跟踪 origin/main,不是 GitHub 上的 stable Release |
--json | 含每一步的机器可读结果 |
输出示例
$ openprogram upgrade status
channel stable (origin/main)
head f5671fd25e4c6ae89e6d77f3fcffc4d4a2c0570a
target a2d7f95633527e182ac850e40aca727aa0f6a3e6
update available
$ openprogram upgrade --dry-run
[OK ] preflight stable → origin/main: 80d77d1ed44c → 1a4101433b13
[OK ] checkout planned (dry run)
[OK ] deps planned (dry run)
[OK ] build planned (dry run)
[OK ] probe planned (dry run)
[OK ] restart planned (dry run)
[OK ] verify planned (dry run)
openprogram update(--check、--force)是遗留命令,会抛 ImportError。请用 openprogram upgrade。
Last updated · 2026-11-25