From b9e5bf3fecca1c38b458b71ea89e26ae436e1c98 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 Admin 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 e3499ef7..c27fb0b1 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 9fa90096..ab0275c3 100644 --- a/src/deployment/blueGreenDeployment.test.mjs +++ b/src/deployment/blueGreenDeployment.test.mjs @@ -15,7 +15,11 @@ test('production frontend starts and validates the candidate before switching ng }) test('production frontend supports both slots and restores nginx on failure', () => { + 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 "\$nginx_config" "\$backup"/) assert.match(script, /cp -f "\$backup" "\$nginx_config"/) assert.match(script, /docker rm -f "\$candidate"/) -- 2.54.0