refactor: clean up CI debug code, keep direct app health validation
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 31s

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
WangDL 2026-05-24 13:01:13 +08:00
parent 844deaf281
commit be59749239

View File

@ -29,12 +29,6 @@ jobs:
cd /tmp/api-server cd /tmp/api-server
npx prisma generate npx prisma generate
npm run build 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 - name: Ensure infrastructure is ready
run: | run: |
@ -87,37 +81,30 @@ jobs:
- name: Start API service - name: Start API service
run: | 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 cd /opt/zhixi/backend
PORT=3000 nohup node dist/main.js > /tmp/zhixi-direct.log 2>&1 & PORT=3000 nohup node dist/main.js > /tmp/zhixi-direct.log 2>&1 &
DIRECT_PID=$! DIRECT_PID=$!
echo "[deploy] Direct PID: $DIRECT_PID"
# Wait for healthy response (up to 15s)
HEALTHY=0 HEALTHY=0
for i in $(seq 1 15); do for i in $(seq 1 15); do
sleep 1 sleep 1
if curl -sf http://localhost:3000/api > /dev/null 2>&1; then 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 HEALTHY=1
break break
fi fi
if ! kill -0 $DIRECT_PID 2>/dev/null; then 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 tail -30 /tmp/zhixi-direct.log
break break
fi fi
done done
# Kill direct instance
kill $DIRECT_PID 2>/dev/null kill $DIRECT_PID 2>/dev/null
wait $DIRECT_PID 2>/dev/null || true wait $DIRECT_PID 2>/dev/null || true
if [ "$HEALTHY" = "1" ]; then if [ "$HEALTHY" = "1" ]; then
sudo systemctl reset-failed zhixi-api 2>/dev/null || true sudo systemctl reset-failed zhixi-api 2>/dev/null || true
sudo systemctl start zhixi-api || true sudo systemctl restart zhixi-api
sleep 2 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 else
echo "[deploy] App failed to start" echo "[deploy] App failed to start"
exit 1 exit 1
@ -136,7 +123,3 @@ jobs:
sleep 5 sleep 5
sudo systemctl is-active zhixi-worker sudo systemctl is-active zhixi-worker
echo "[deploy] zhixi-worker active OK" 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)"