From a96cbbd57d4090f70d85f508572ebbd65eedd857 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sun, 20 Sep 2026 23:39:39 +0800 Subject: [PATCH] fix: preserve stable Client proxy port --- scripts/deploy-production.sh | 6 +++--- src/deployment/blueGreenDeployment.test.mjs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/deploy-production.sh b/scripts/deploy-production.sh index e3499ef..c27fb0b 100644 --- a/scripts/deploy-production.sh +++ b/scripts/deploy-production.sh @@ -62,12 +62,12 @@ compose() { case "$service" in admin-web) base_port=9001 - nginx_config=/www/server/panel/vhost/nginx/admin.buggoglobal.com.conf + nginx_config=/www/server/panel/vhost/nginx/00-blue-green-admin-web.conf legacy_container=firstleg-prod-admin-web ;; client-web) base_port=9002 - nginx_config=/www/server/panel/vhost/nginx/app.buggoglobal.com.conf + nginx_config=/www/server/panel/vhost/nginx/00-blue-green-client-web.conf legacy_container=firstleg-prod-client-web ;; *) echo "不支持蓝绿部署的前端服务: $service" >&2; exit 2 ;; @@ -102,7 +102,7 @@ fi if [ "$active_slot" = blue ]; then target_slot=green; else target_slot=blue; fi [ "$active_slot" = legacy ] && target_slot=green -if [ "$target_slot" = blue ]; then target_port="$base_port"; else target_port=$((base_port + 10000)); fi +if [ "$target_slot" = blue ]; then target_port=$((base_port + 20000)); else target_port=$((base_port + 10000)); fi candidate="${legacy_container}-${target_slot}" docker rm -f "$candidate" >/dev/null 2>&1 || true diff --git a/src/deployment/blueGreenDeployment.test.mjs b/src/deployment/blueGreenDeployment.test.mjs index 8576a08..35a34f9 100644 --- a/src/deployment/blueGreenDeployment.test.mjs +++ b/src/deployment/blueGreenDeployment.test.mjs @@ -13,7 +13,11 @@ test('client production deployment switches healthy blue-green slots atomically' const nginx = script.indexOf('nginx -t || ! nginx -s reload') const stop = script.indexOf('docker stop --time 30 "$active_container"') assert.ok(start >= 0 && start < health && health < nginx && nginx < stop) + assert.match(script, /target_port=\$\(\(base_port \+ 20000\)\)/) assert.match(script, /target_port=\$\(\(base_port \+ 10000\)\)/) + assert.match(script, /00-blue-green-admin-web\.conf/) + assert.match(script, /00-blue-green-client-web\.conf/) + assert.doesNotMatch(script, /nginx_config=\/www\/server\/panel\/vhost\/nginx\/(?:admin|app)\.buggoglobal\.com\.conf/) assert.match(script, /cp -f "\$backup" "\$nginx_config"/) }) -- 2.54.0