refactor: clean up CI debug code, keep direct app health validation
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 31s
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:
parent
844deaf281
commit
be59749239
@ -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)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user