refactor(deploy): minimize downtime and fix health check subpath (CLAUDE.md guidelines)
Deploy to Production / Build Release Package (push) Failing after 16s
Deploy to Production / Deploy to Production Server (push) Has been skipped
Deploy to Production / Post-Deployment Checks (push) Has been skipped
Snapshot Admin Deployment / build-and-deploy (push) Failing after 34s
Quant Engine CI/CD Pipeline / validate-core (push) Failing after 2m18s
Quant Engine CI/CD Pipeline / validate-ui-and-storage (push) Has been skipped

This commit is contained in:
2026-06-29 10:55:40 +09:00
parent b475bef123
commit c888486635
+12 -16
View File
@@ -107,20 +107,15 @@ jobs:
chmod 600 ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${{ env.DEPLOY_HOST }} >> ~/.ssh/known_hosts 2>/dev/null || true ssh-keyscan -H ${{ env.DEPLOY_HOST }} >> ~/.ssh/known_hosts 2>/dev/null || true
- name: Stop Service and Create Backup - name: Create Backup
run: | run: |
echo "📦 Stopping service and creating backup..." echo "📦 Creating backup of current deployment..."
ssh -i ~/.ssh/id_ed25519 ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} << 'EOF' ssh -i ~/.ssh/id_ed25519 ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} << 'EOF'
set -e set -e
BACKUP_DIR="/home/kjh2064/quantengine_backup" BACKUP_DIR="/home/kjh2064/quantengine_backup"
BACKUP_NAME="quantengine_$(date +%Y%m%d_%H%M%S)" BACKUP_NAME="quantengine_$(date +%Y%m%d_%H%M%S)"
# Stop service # Create backup without stopping the service (minimize downtime)
echo "⏹️ Stopping quantengine service..."
sudo systemctl stop ${{ env.SERVICE_NAME }}
sleep 2
# Create backup
mkdir -p $BACKUP_DIR mkdir -p $BACKUP_DIR
if [ -d ${{ env.DEPLOY_PATH }} ]; then if [ -d ${{ env.DEPLOY_PATH }} ]; then
cp -r ${{ env.DEPLOY_PATH }} "$BACKUP_DIR/$BACKUP_NAME" cp -r ${{ env.DEPLOY_PATH }} "$BACKUP_DIR/$BACKUP_NAME"
@@ -184,19 +179,20 @@ jobs:
rm -rf /tmp/quant-deploy rm -rf /tmp/quant-deploy
EOF EOF
- name: Start Service - name: Restart Service
run: | run: |
echo "🔄 Starting quantengine service..." echo "🔄 Restarting quantengine service to apply changes (Downtime minimal)..."
ssh -i ~/.ssh/id_ed25519 ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} << 'EOF' ssh -i ~/.ssh/id_ed25519 ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} << 'EOF'
set -e set -e
# Start service # Restart service
sudo systemctl start ${{ env.SERVICE_NAME }} echo "⏹️ Restarting quantengine service..."
sudo systemctl restart ${{ env.SERVICE_NAME }}
sleep 3 sleep 3
# Check status # Check status
if sudo systemctl is-active --quiet ${{ env.SERVICE_NAME }}; then if sudo systemctl is-active --quiet ${{ env.SERVICE_NAME }}; then
echo "✅ ${{ env.SERVICE_NAME }} started successfully" echo "✅ ${{ env.SERVICE_NAME }} restarted successfully"
sudo systemctl status ${{ env.SERVICE_NAME }} | head -5 sudo systemctl status ${{ env.SERVICE_NAME }} | head -5
else else
echo "❌ ${{ env.SERVICE_NAME }} failed to start" echo "❌ ${{ env.SERVICE_NAME }} failed to start"
@@ -209,13 +205,13 @@ jobs:
run: | run: |
echo "🧪 Running health checks..." echo "🧪 Running health checks..."
# Wait for service to be ready (localhost:5000 through Nginx) # Wait for service to be ready (localhost:5000/quant/ through Nginx/Kestrel)
for i in {1..30}; do for i in {1..30}; do
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
"http://127.0.0.1:5000/" || echo "000") "http://127.0.0.1:5000/quant/" || echo "000")
if [ "$HTTP_CODE" = "200" ]; then if [ "$HTTP_CODE" = "200" ]; then
echo "✅ Health check passed (HTTP $HTTP_CODE at localhost:5000)" echo "✅ Health check passed (HTTP $HTTP_CODE at localhost:5000/quant/)"
break break
fi fi