From 5d2796337be7868d08abff489a9d0de86e78c0c1 Mon Sep 17 00:00:00 2001 From: wangbo Date: Wed, 29 Jul 2026 02:09:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E7=AD=89=E5=BE=85=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E5=85=A5=E5=8F=A3=E5=AE=8C=E6=88=90=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NGINX 优雅重载期间旧 worker 可能短暂继续返回 200,单次状态码断言会误触发安全回滚。改为最多轮询 15 秒等待维护页返回 503。\n\n验证:bash -n、ShellCheck、git diff --check、真实维护页 503 与恢复后公网 200。 --- scripts/cluster/migrate-production.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/cluster/migrate-production.sh b/scripts/cluster/migrate-production.sh index 7b4040f..68372cc 100755 --- a/scripts/cluster/migrate-production.sh +++ b/scripts/cluster/migrate-production.sh @@ -138,9 +138,17 @@ chmod 0600 "$old_site_backup" install -m 0644 /etc/nginx/sites-available/ai.51easyai.com-maintenance "$active_site" nginx -t systemctl reload nginx -curl -ksS --resolve ai.51easyai.com:443:127.0.0.1 \ - -o /dev/null -w '%{http_code}' https://ai.51easyai.com/api/v1/healthz | - grep -qx 503 +maintenance_code= +for _ in $(seq 1 15); do + maintenance_code=$(curl -ksS --resolve ai.51easyai.com:443:127.0.0.1 \ + -o /dev/null -w '%{http_code}' https://ai.51easyai.com/api/v1/healthz || true) + [[ $maintenance_code == 503 ]] && break + sleep 1 +done +[[ $maintenance_code == 503 ]] || { + echo "maintenance NGINX did not become active: HTTP $maintenance_code" >&2 + exit 1 +} docker stop --time 60 easyai-ai-gateway-api-1 >/dev/null postgres_user=$(docker inspect easyai-ai-gateway-postgres-1 \