initialising for ci-cd pipeline
CI/CD - ERP Core / scripts (pull_request) Failing after 12m21s
CI/CD - ERP Core / e2e-typecheck (pull_request) Failing after 13m13s
CI/CD - ERP Core / frontend (pull_request) Failing after 14m5s
CI/CD - ERP Core / backend (pull_request) Failing after 14m57s
CI/CD - ERP Core / detect (pull_request) Failing after 13m42s
CI/CD - ERP Core / Build & Deploy (pull_request) Failing after 12m47s
CI/CD - ERP Core / ci-ok (pull_request) Failing after 14m58s

This commit is contained in:
2026-09-16 11:53:55 +05:30
parent 666979cf22
commit 8e472ac996
48 changed files with 2224 additions and 62 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# ci-cd.yml › Build & Deploy › Verify backend — wait until erpcore.service answers /health, and fail the job otherwise.
#
# EF migrations + seeding run BEFORE the app starts listening, so a slow start is normal. Only a
# crash (unit failed, or systemd auto-restarted it) or the ceiling counts as failure — a crashed
# service fails within seconds, and a slow but live migration is never cut short by a tight timer.
#
# Env: SERVICE (erpcore.service) · BACKEND_PORT (5220) · HEALTH_TIMEOUT seconds (300)
# RESTARTS_AT_START — NRestarts captured right after `systemctl start` (the Start step exports it)
set -euo pipefail
service="${SERVICE:-erpcore.service}"
port="${BACKEND_PORT:-5220}"
timeout="${HEALTH_TIMEOUT:-300}"
restarts_at_start="${RESTARTS_AT_START:-$(systemctl show -p NRestarts --value "$service")}"
show_journal() { journalctl -u "$service" -n 80 --no-pager || true; }
deadline=$((SECONDS + timeout))
while ((SECONDS < deadline)); do
if curl -fsS --max-time 5 -o /dev/null "http://127.0.0.1:$port/health" 2>/dev/null; then
echo "✅ $service is healthy (after ${SECONDS}s)"
exit 0
fi
state="$(systemctl show -p ActiveState --value "$service")"
restarts="$(systemctl show -p NRestarts --value "$service")"
if [[ "$state" == failed || "$restarts" != "$restarts_at_start" ]]; then
echo "❌ $service crashed during startup (state=$state, restarts $restarts_at_start → $restarts)" >&2
show_journal
exit 1
fi
sleep 3
done
echo "❌ $service did not answer /health within ${timeout}s (still starting? DB reachable?)" >&2
show_journal
exit 1