Files
blog/infra/deploy/rollback-dryrun.sh
wait4xandGLM-5.3 f16b9487d3 feat(deploy): 发布链地基三件套——webhook 骨架/构建占位/回滚干跑
- webhook-receive.sh:HMAC 骨架 + 仅 main 分支触发(干跑验证两条 ref 路径)
- build.sh:锁发布链形态与路径约定,astro 命令留 Phase 1 TODO
- rollback-dryrun.sh:回滚四前置条件验证 + 人为操作手册(秒级回 18090)
- staging 落用户区 ~/docker_apps/blog/www-staging(宿主 sudo 不可用,nginx 以 root 读用户目录无碍)

验证: webhook 干跑 main accepted / non-main ignored;rollback-dryrun
      四要素 ok(halo vhost/容器/响应/staging)

Co-authored-by: GLM-5.3
2026-10-24 22:10:59 +08:00

34 lines
1.4 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# 回滚预案干跑:验证回滚前置条件齐备,并打印真实切换命令(不执行)
#
# 背景:Phase 4 上线时 wait4x.online 的 nginx 从 proxy_pass 18090(Halo)
# 切到静态目录;任何时刻回滚 = 把 location 改回 18090。本脚本在 Phase 0
# 确认三要素存在,给人一条可复制的回滚路径。
set -e
NGINX_DEFAULT=/etc/nginx/sites-available/default
STAGING="$HOME/docker_apps/blog/www-staging"
fail=0
check() { if eval "$2"; then echo " ok $1"; else echo " FAIL $1"; fail=1; fi }
check "halo vhost 存在(回滚目标 upstream 可达配置)" \
"grep -q 'proxy_pass http://127.0.0.1:18090' $NGINX_DEFAULT"
check "halo 容器存活(回滚有意义)" \
"docker inspect -f '{{.State.Status}}' halo-halo-1 | grep -q running"
check "Halo 本机响应" \
"curl -sf http://127.0.0.1:18090 -o /dev/null"
check "staging 占位目录就绪" \
"test -f $STAGING/index.html"
cat <<'EOF'
回滚操作手册(人为执行,勿自动化):
1. 编辑 /etc/nginx/sites-available/default 中 wait4x.online 的 location /:
proxy_pass http://127.0.0.1:18090; # 从 root <staging> 改回
2. nginx -t && systemctl reload nginx
3. ESA 控制台刷新缓存(或等待 TTL)
预期效果:秒级回到 Halo;静态文件目录保留不动,可再次前切。
EOF
[ "$fail" = "0" ] && echo "rollback dry-run: all preconditions ok" || { echo "rollback dry-run: FAILURES above"; exit 1; }