From be59749239719004b674c45f62bee6a8294f6ac2 Mon Sep 17 00:00:00 2001 From: WangDL Date: Sun, 24 May 2026 13:01:13 +0800 Subject: [PATCH] refactor: clean up CI debug code, keep direct app health validation Co-Authored-By: Claude Opus 4.7 --- .gitea/workflows/deploy.yml | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 443f1dd..232e840 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -29,12 +29,6 @@ jobs: cd /tmp/api-server npx prisma generate npm run build - if [ ! -f dist/main.js ] && [ -f dist/src/main.js ]; then - echo "[build] Moving dist/src/* to dist/" - mv dist/src/* dist/ - rm -rf dist/src - fi - ls -la dist/main.js - name: Ensure infrastructure is ready run: | @@ -87,37 +81,30 @@ jobs: - name: Start API service run: | - # Stop existing service - sudo systemctl stop zhixi-api 2>/dev/null || true - sleep 2 - # Try running directly to validate app works cd /opt/zhixi/backend PORT=3000 nohup node dist/main.js > /tmp/zhixi-direct.log 2>&1 & DIRECT_PID=$! - echo "[deploy] Direct PID: $DIRECT_PID" - # Wait for healthy response (up to 15s) HEALTHY=0 for i in $(seq 1 15); do sleep 1 if curl -sf http://localhost:3000/api > /dev/null 2>&1; then - echo "[deploy] Direct app healthy after ${i}s!" + echo "[deploy] App healthy after ${i}s" HEALTHY=1 break fi if ! kill -0 $DIRECT_PID 2>/dev/null; then - echo "[deploy] Direct app died — log:" + echo "[deploy] App crashed — log:" tail -30 /tmp/zhixi-direct.log break fi done - # Kill direct instance kill $DIRECT_PID 2>/dev/null wait $DIRECT_PID 2>/dev/null || true if [ "$HEALTHY" = "1" ]; then sudo systemctl reset-failed zhixi-api 2>/dev/null || true - sudo systemctl start zhixi-api || true + sudo systemctl restart zhixi-api sleep 2 - sudo systemctl is-active zhixi-api && echo "[deploy] systemd active OK" || echo "[deploy] systemd pending (direct run verified OK)" + curl -sf http://localhost:3000/api > /dev/null && echo "[deploy] API health OK" else echo "[deploy] App failed to start" exit 1 @@ -136,7 +123,3 @@ jobs: sleep 5 sudo systemctl is-active zhixi-worker echo "[deploy] zhixi-worker active OK" - - - name: Health check - run: | - curl -sf http://localhost:3000/api && echo "[deploy] API health OK" || echo "[deploy] API health check failed (non-fatal)"