#!/usr/bin/env bash # ============================================ # Projet : API-KA # Fichier : scripts/healthcheck.sh # Node : m3u96b # Author : Simon-Pierre Boucher # Contact : contact@spboucher.ai # Date : 2026-08-16 # ============================================ # Vérification de santé utilisée par systemd / monitoring. # Exit 0 si l'API répond et que la base est OK, exit 1 sinon. set -uo pipefail URL="http://127.0.0.1:${API_PORT:-8000}/health" RESPONSE="$(curl -fsS --max-time 10 "$URL" 2>/dev/null)" || { echo "❌ API-KA injoignable sur $URL" exit 1 } if echo "$RESPONSE" | grep -q '"database": *"ok"'; then echo "✅ API-KA en bonne santé ($URL)" exit 0 fi echo "❌ API-KA dégradée : $RESPONSE" exit 1