Wiki/scripts/healthcheck.sh
Corentin JOGUET 1d71364c6e
Some checks are pending
CI / Lint bridge (Biome) (push) Waiting to run
CI / Type-check bridge (push) Blocked by required conditions
CI / Tests unit bridge (push) Blocked by required conditions
CI / Tests integration bridge (push) Blocked by required conditions
CI / Security scan (push) Waiting to run
CI / Docker build + healthcheck (push) Blocked by required conditions
feat(seed): add I4 forms publics + space etudiant + I5 healthcheck etendu
I4 — Forms publics + space etudiant :
- baserow/seed/seed_forms.py : cree forms publics sur attribution + intervention
  (saisie heures via lien sans compte). Form cree OK, field-options endpoint
  retourne 404 sur Baserow 1.30 — a investiguer (URL different selon version).
- docmost/setup/create-space-etudiant.py : cree space prive + invite etudiant
  + page Welcome template. Slug strict lettres+chiffres only (fix Docmost).

I5 — Ops :
- scripts/healthcheck.sh : check UI + API health (Docmost+Baserow), affiche
  status containers Docker. 4/4 OK en local.
- scripts/cron-install.sh : installe cron quotidien backup + healthcheck */5min.

Makefile : targets seed-baserow-forms, create-space-etudiant. Tous les targets
utilisent maintenant .venv/ local pour eviter pip systeme.

.gitignore : exclut .venv/ + __pycache__/.
2026-05-07 18:49:00 +02:00

78 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# scripts/healthcheck.sh — health check stack + APIs internes
set -euo pipefail
DOCMOST_URL="${DOCMOST_URL:-http://localhost:3000}"
BASEROW_URL="${BASEROW_URL:-http://localhost:8080}"
BRIDGE_URL="${BRIDGE_URL:-}"
TIMEOUT="${HEALTHCHECK_TIMEOUT:-10}"
red() { printf '\033[31m%s\033[0m\n' "$1"; }
green() { printf '\033[32m%s\033[0m\n' "$1"; }
yellow(){ printf '\033[33m%s\033[0m\n' "$1"; }
check_http() {
local name="$1"
local url="$2"
if curl -sf --max-time "$TIMEOUT" -o /dev/null "$url"; then
green " OK $name : $url"
return 0
else
red " KO $name : $url"
return 1
fi
}
check_health_endpoint() {
local name="$1"
local url="$2"
local expected="$3"
local resp
resp=$(curl -sf --max-time "$TIMEOUT" "$url" || echo "")
if echo "$resp" | grep -q "$expected"; then
green " OK $name (API health endpoint)"
return 0
else
red " KO $name (API health endpoint) — got: ${resp:0:80}"
return 1
fi
}
echo "Healthcheck stack (timeout ${TIMEOUT}s)"
echo "----------------------------------------"
ok=0
total=0
((++total)) || true
check_http "Docmost UI " "$DOCMOST_URL" && ((++ok)) || true
((++total)) || true
check_health_endpoint "Docmost API" "$DOCMOST_URL/api/health" "ok" && ((++ok)) || true
((++total)) || true
check_http "Baserow UI " "$BASEROW_URL" && ((++ok)) || true
((++total)) || true
check_http "Baserow API" "$BASEROW_URL/api/_health/" && ((++ok)) || true
if [ -n "$BRIDGE_URL" ]; then
((++total)) || true
check_health_endpoint "Bridge " "$BRIDGE_URL/api/health" "ok" && ((++ok)) || true
fi
# Container status (si Docker dispo)
if command -v docker >/dev/null 2>&1; then
echo ""
echo "Containers :"
docker compose ps --format " {{.Name}}: {{.Status}}" 2>&1 | head -10 || yellow " (compose not running here)"
fi
echo "----------------------------------------"
if [ "$ok" -eq "$total" ]; then
green "Healthcheck : $ok/$total OK"
exit 0
else
red "Healthcheck : $ok/$total OK"
exit 1
fi