devops: 割接后 server 部署轨道切为仅 Ali 主轨(移除 EC2 轨)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
This commit is contained in:
+24
-13
@@ -4,13 +4,14 @@
|
||||
# assets by tag (manual rollback). Does NOT touch the web app, marketing site,
|
||||
# or version.yaml.
|
||||
#
|
||||
# Target is EC2 by default. During the EC2→Ali migration, set DEPLOY_TARGET=ali
|
||||
# plus DEPLOY_HOST/DEPLOY_USER/DEPLOY_SSH_KEY to deploy to the Alibaba Cloud box.
|
||||
# - ec2 (default): stop jiu → swap binary → start jiu → health check →
|
||||
# reload nginx inside the pangolin-edge container.
|
||||
# - ali: swap binary only (jiu.service stays stopped — the Ali DB is a
|
||||
# read-only replica until cutover; backend is started at cutover) →
|
||||
# reload the host nginx with the standalone (listen 443) config.
|
||||
# Targets (post-cutover 2026-07-02: Ali is the live primary; the EC2 jiu stack
|
||||
# is decommissioned — deploying there would resurrect a backend against a stale
|
||||
# database, so the workflow no longer calls the ec2 branch):
|
||||
# - ali: stop jiu → swap binary → start jiu → health check (:8081) →
|
||||
# reload the host nginx (transition listen-8443 config).
|
||||
# - ec2 (legacy default, kept for manual rollback of pre-cutover tags only):
|
||||
# stop jiu → swap binary → start jiu → health check → reload nginx
|
||||
# inside the pangolin-edge container.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
@@ -53,14 +54,13 @@ if [ -f dist/jiu-gencode ]; then
|
||||
fi
|
||||
|
||||
if [ "$DEPLOY_TARGET" = "ali" ]; then
|
||||
# --- Alibaba Cloud (shadow target, pre-cutover) ---
|
||||
# Swap the binary but DO NOT start jiu: the Ali DB is a read-only replica, so
|
||||
# the backend's startup AutoMigrate/backfill would fail. jiu.service is started
|
||||
# only at cutover (after the replica is promoted to primary). Reload the host
|
||||
# nginx with the standalone listen-443 config.
|
||||
# --- Alibaba Cloud (live primary since the 2026-07-02 cutover) ---
|
||||
# Full swap-and-restart: jiu.service runs against the promoted local primary
|
||||
# DB on :8081; nginx serves the transition listen-8443 config.
|
||||
${SSH} "${TARGET_USER}@${TARGET_HOST}" << 'ENDSSH'
|
||||
set -e
|
||||
|
||||
systemctl stop jiu
|
||||
cp /tmp/jiu-server /opt/jiu/backend/jiu-server
|
||||
chmod +x /opt/jiu/backend/jiu-server
|
||||
|
||||
@@ -73,10 +73,21 @@ if [ -f /tmp/jiu-gencode ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
systemctl start jiu
|
||||
echo "Waiting for health check..."
|
||||
for i in $(seq 1 30); do
|
||||
if curl -f http://localhost:8081/health > /dev/null 2>&1; then
|
||||
echo "Health check passed"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
curl -f http://localhost:8081/health > /dev/null || { echo "Health check failed!"; exit 1; }
|
||||
|
||||
cp /tmp/nginx-jiu.conf /etc/nginx/conf.d/jiu.conf
|
||||
nginx -t && systemctl reload nginx
|
||||
|
||||
echo "Ali server staged (binary swapped, jiu.service left stopped, nginx reloaded)"
|
||||
echo "Ali server deploy complete!"
|
||||
ENDSSH
|
||||
else
|
||||
# --- EC2 (live primary) ---
|
||||
|
||||
Reference in New Issue
Block a user