fix: restore simple systemd restart — server rate-limit manually cleared
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
bb555d4a72
commit
dffcd0192d
@ -79,35 +79,16 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd /opt/zhixi/backend && npx prisma generate
|
cd /opt/zhixi/backend && npx prisma generate
|
||||||
|
|
||||||
- name: Start API service
|
- name: Restart API service
|
||||||
run: |
|
run: |
|
||||||
cd /opt/zhixi/backend
|
sudo systemctl reset-failed zhixi-api 2>/dev/null || true
|
||||||
PORT=3000 nohup node dist/main.js > /tmp/zhixi-direct.log 2>&1 &
|
sudo systemctl restart zhixi-api
|
||||||
DIRECT_PID=$!
|
sleep 3
|
||||||
HEALTHY=0
|
if curl -sf http://localhost:3000/api > /dev/null 2>&1; then
|
||||||
for i in $(seq 1 15); do
|
echo "[deploy] API health OK"
|
||||||
sleep 1
|
|
||||||
if curl -sf http://localhost:3000/api > /dev/null 2>&1; then
|
|
||||||
echo "[deploy] App healthy after ${i}s"
|
|
||||||
HEALTHY=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if ! kill -0 $DIRECT_PID 2>/dev/null; then
|
|
||||||
echo "[deploy] App crashed — log:"
|
|
||||||
tail -30 /tmp/zhixi-direct.log
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
kill $DIRECT_PID 2>/dev/null
|
|
||||||
wait $DIRECT_PID 2>/dev/null || true
|
|
||||||
if [ "$HEALTHY" = "1" ]; then
|
|
||||||
echo "[deploy] App verified OK, restarting via systemd..."
|
|
||||||
sudo systemctl reset-failed zhixi-api 2>/dev/null || true
|
|
||||||
sudo systemctl restart zhixi-api || true
|
|
||||||
sleep 3
|
|
||||||
curl -sf http://localhost:3000/api > /dev/null && echo "[deploy] systemd health OK" || echo "[deploy] systemd restart pending (app verified working)"
|
|
||||||
else
|
else
|
||||||
echo "[deploy] App failed to start"
|
echo "[deploy] Health check failed — checking logs:"
|
||||||
|
sudo journalctl -u zhixi-api --no-pager -n 20
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user