All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 52s
44 lines
1.7 KiB
Bash
Executable File
44 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
echo "[1/6] Backing up nginx confs..."
|
|
./scripts/backup_nginx_confs.sh
|
|
|
|
echo "[2/6] Checking required environment variables..."
|
|
REQUIRED=("PORT" "APP_HOST" "DEFAULT_STORAGE" "SIGNER_WS_URL" "SIGNER_API_KEY")
|
|
MISSING=()
|
|
for v in "${REQUIRED[@]}"; do
|
|
if [ -z "${!v:-}" ]; then MISSING+=("$v"); fi
|
|
done
|
|
if [ ${#MISSING[@]} -gt 0 ]; then
|
|
echo "Missing env vars: ${MISSING[*]}" >&2; exit 1; fi
|
|
|
|
echo "[3/6] Building backend..."
|
|
npm run build --silent
|
|
|
|
echo "[4/6] Starting backend (detached) if not already running..."
|
|
if ! nc -z localhost "${PORT}" >/dev/null 2>&1; then
|
|
nohup node dist/server.js > logs/backend.out 2>&1 &
|
|
echo $! > logs/server.pid
|
|
sleep 2
|
|
fi
|
|
if ! nc -z localhost "${PORT}" >/dev/null 2>&1; then echo "Backend not listening on ${PORT}" >&2; exit 1; fi
|
|
|
|
echo "[5/6] Curl checks - backend health and key routes..."
|
|
set +e
|
|
curl -fsS "http://localhost:${PORT}/api/v1/health" | jq . >/dev/null && echo "OK /api/v1/health" || { echo "FAIL /api/v1/health"; exit 1; }
|
|
curl -fsS -X OPTIONS -H "Origin: ${APP_HOST}" "http://localhost:${PORT}/api/v1/health" -o /dev/null && echo "OK CORS preflight" || { echo "FAIL CORS"; exit 1; }
|
|
set -e
|
|
|
|
echo "[6/6] External service checks..."
|
|
echo "- Checking mempool signet..."
|
|
curl -fsS "https://mempool2.4nkweb.com/fr/docs/api/rest" -o /dev/null && echo "OK mempool" || echo "WARN mempool unreachable"
|
|
echo "- Checking signer relay ws..."
|
|
if command -v wscat >/dev/null 2>&1; then
|
|
( timeout 3 wscat -c "${SIGNER_WS_URL/ws:/wss:}" >/dev/null 2>&1 && echo "OK signer ws connect" ) || echo "WARN signer ws connect failed"
|
|
else
|
|
echo "wscat not installed; skipping ws check"
|
|
fi
|
|
|
|
echo "All checks done."
|