#!/bin/bash set -euo pipefail BTC_CONTAINER="4nk-bitcoin" RELAY_CONTAINERS=("4nk-sdk-relay1" "4nk-sdk-relay2" "4nk-sdk-relay3") STORAGE_CONTAINER="4nk-sdk-storage" SIGNER_CONTAINER="4nk-sdk-signer" IHMSERVER_CONTAINER="4nk-node-ihm-client" TOR_CONTAINER="4nk-node-tor" NGINX_CONTAINER="4nk-nginx" # si présent # Attendre la fin de l'IBD du Bitcoin Core echo "Relancer les healthchecks après l'IBD terminé..." while true; do if docker ps -q -f name="^${BTC_CONTAINER}$" >/dev/null 2>&1; then INFO=$(docker exec "$BTC_CONTAINER" bitcoin-cli -signet getblockchaininfo 2>/dev/null || true) if echo "$INFO" | grep -q '"initialblockdownload":false'; then echo "IBD terminé sur $BTC_CONTAINER" break else echo "IBD en cours sur $BTC_CONTAINER..."; fi else echo "Bitcoin container non trouvé, tentative de reprise..." fi sleep 60 done # Redémarrer les conteneurs critiques pour relancer les healthchecks RESTART_LIST=("$BTC_CONTAINER" "${RELAY_CONTAINERS[@]}" "$STORAGE_CONTAINER" "$SIGNER_CONTAINER" "$IHMSERVER_CONTAINER" "$TOR_CONTAINER") for c in "${RESTART_LIST[@]}"; do if docker ps -a | awk '{print $NF}' | tail -n +2 | grep -qx "$c"; then echo "Redémarrage de $c ..." docker restart "$c" >/dev/null 2>&1 || true fi done # Vérification rapide des conteneurs echo "État des conteneurs après redémarrage:" docker ps -a # Vérifier des endpoints simples si accessibles echo "Vérification rapide des endpoints (si disponibles) :" ENDPOINTS=( "http://localhost:8081/" # storage "http://localhost:8000/" # blindbit "http://localhost:9090/" # signer "http://localhost:3003/" # ihm web "http://localhost:8091/" # relay1 "http://localhost:8093/" # relay2 "http://localhost:8095/" # relay3 ) for url in "${ENDPOINTS[@]}"; do if curl -sS --max-time 5 "$url" >/dev/null 2>&1; then echo "OK: $url reachable" else echo "WARN: $url not reachable" fi done