4NK_node/scripts/health_after_ibd.sh
Debian bb61be04a4
Some checks failed
CI - 4NK_node / Code Quality (push) Failing after 50s
CI - 4NK_node / Unit Tests (push) Failing after 29s
CI - 4NK_node / Integration Tests (push) Failing after 12s
CI - 4NK_node / Security Tests (push) Failing after 27s
CI - 4NK_node / Docker Build & Test (push) Failing after 9s
CI - 4NK_node / Documentation Tests (push) Failing after 4s
CI - 4NK_node / Security Audit (push) Successful in 3s
CI - 4NK_node / Release Guard (push) Has been skipped
CI - 4NK_node / Performance Tests (push) Successful in 28s
CI - 4NK_node / Notify (push) Failing after 2s
CI - 4NK_node / Publish Release (push) Has been skipped
clean
2025-09-04 08:13:43 +00:00

60 lines
1.9 KiB
Bash
Executable File

#!/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