From bb29c8abafe08678dc31d42a11982fef720d7af6 Mon Sep 17 00:00:00 2001 From: wait4xx Date: Sun, 1 Nov 2026 09:58:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E6=9E=84=E5=BB=BA=E6=8A=93?= =?UTF-8?q?=E5=8F=96=E9=80=9A=E9=81=93=E5=8F=AF=E9=85=8D+=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=97=A5=E5=BF=97=E8=90=BD=E7=9B=98=E2=80=94=E2=80=94?= =?UTF-8?q?ESA=20522=20=E4=BA=8B=E6=95=85=E5=8F=8C=E6=A0=B9=E6=B2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - build.sh:BLOG_GIT_URL 环境变量(默认公网,同机构建可指内网 http://127.0.0.1:13020);每次构建 remote set-url 后 fetch—— 2026-10-26 事故:ESA 边缘对 git.wait4x.online 522 时公网 fetch set -e 静默死,staging 冻结 150s+ 无痕 - webhook_receiver.py:构建输出落盘 ~/docker_apps/blog/build.log (capture_output 丢弃=黑洞,本次事故"构建为何没跑"零证据); 与运行副本双同步纪律维持 - 宿主 unit 补 BLOG_GIT_URL 内网通道(配置在 unit 不在仓——主机 特定值不污染仓库默认) 验证: 手动构建实测 stamp=19b2390+robots.txt 352B 上线;18743 测试 床恢复 200;smoke 对 staging 软门容忍符合 T1 转硬门前设计 Spec: none (发布链通道与可观测性修复,事故驱动) Co-authored-by: GLM-5.3 --- infra/deploy/build.sh | 8 +++++++- infra/deploy/webhook_receiver.py | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/infra/deploy/build.sh b/infra/deploy/build.sh index 0d76e43..7d9d35b 100755 --- a/infra/deploy/build.sh +++ b/infra/deploy/build.sh @@ -6,15 +6,21 @@ # 发布。改为独立构建仓 fetch+reset 硬跟 main:线上=远端 main,确定性闭环。 # blog 仓已公开,匿名 fetch 无需凭据。 set -e +# 抓取 URL:默认公网;同机构建可由宿主环境变量覆盖为内网 +# (2026-10-26 事故:ESA 边缘对 git.wait4x.online 522 时公网 fetch 失败, +# set -e 下静默死、staging 冻结——内网通道必须可用) +BLOG_GIT_URL="${BLOG_GIT_URL:-https://git.wait4x.online/wait4x/blog.git}" BUILD_REPO="$HOME/docker_apps/blog/build-repo" STAGING="$HOME/docker_apps/blog/www-staging" if [ ! -d "$BUILD_REPO/.git" ]; then echo "[build] 首次克隆构建仓" - git clone https://git.wait4x.online/wait4x/blog.git "$BUILD_REPO" + git clone "$BLOG_GIT_URL" "$BUILD_REPO" fi cd "$BUILD_REPO" +# 每次构建把 origin 指向配置的 URL(同机构建走内网通道;公网 522 时仍可发布) +git remote set-url origin "$BLOG_GIT_URL" git fetch origin main git reset --hard origin/main git clean -fd --exclude node_modules diff --git a/infra/deploy/webhook_receiver.py b/infra/deploy/webhook_receiver.py index 176f5ca..f718217 100644 --- a/infra/deploy/webhook_receiver.py +++ b/infra/deploy/webhook_receiver.py @@ -85,11 +85,15 @@ class Handler(BaseHTTPRequestHandler): def _run_build(self) -> None: with BUILD_LOCK: - subprocess.run( - ["bash", str(build_script())], - capture_output=True, timeout=1200, - cwd=str(BUILD_REPO), - ) + # 输出落盘:capture_output 丢弃是调试黑洞(2026-10-26 ESA 522 + # 事件中构建静默死、staging 冻结无任何可见痕迹) + log = Path.home() / "docker_apps/blog/build.log" + with open(log, "wb") as fh: + subprocess.run( + ["bash", str(build_script())], + stdout=fh, stderr=subprocess.STDOUT, timeout=1200, + cwd=str(BUILD_REPO), + ) def log_message(self, fmt: str, *args: object) -> None: # 静默常规访问日志(健康探针会刷屏);错误仍走默认 stderr