#!/bin/bash # Script de surveillance en temps réel de la progression des services LeCoffre Node # Affiche la progression des différents processus (IBD, scans, etc.) en continu set -e # Couleurs pour l'affichage RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' NC='\033[0m' # No Color # Fonction pour effacer l'écran et afficher le header clear_and_header() { clear echo -e "${BLUE}========================================${NC}" echo -e "${BLUE} LeCoffre Node - Live Progress Monitor${NC}" echo -e "${BLUE}========================================${NC}" echo -e "${YELLOW}Last updated: $(date)${NC}" echo } # Fonction pour afficher la progression Bitcoin show_bitcoin_progress() { local container_name="bitcoin-signet" if docker ps --format "table {{.Names}}" | grep -q "$container_name"; then echo -e "${CYAN}Bitcoin Progress:${NC}" local info=$(docker exec "$container_name" bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblockchaininfo 2>/dev/null || echo '{}') local blocks=$(echo "$info" | jq -r '.blocks // 0') local headers=$(echo "$info" | jq -r '.headers // 0') local progress=0 if [ "$headers" -gt 0 ]; then progress=$((blocks * 100 / headers)) fi if [ "$blocks" -eq "$headers" ] && [ "$blocks" -gt 0 ]; then echo -e " ${GREEN}✓ Bitcoin sync complete: $blocks blocks${NC}" else echo -e " ${YELLOW}⏳ Bitcoin IBD: $blocks/$headers blocks ($(($headers - $blocks)) remaining) - $progress%${NC}" # Afficher une barre de progression local bar_length=50 local filled_length=$((progress * bar_length / 100)) local bar="" for ((i=0; i/dev/null | grep -E "(waiting for|blocks to download|IBD)" | tail -1 || echo "") if [ -n "$logs" ]; then echo -e " ${YELLOW}⏳ SDK Relay IBD: $logs${NC}" else local response=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8091/ 2>/dev/null || echo "000") if [ "$response" = "200" ]; then echo -e " ${GREEN}✓ SDK Relay ready: WebSocket server responding${NC}" else echo -e " ${YELLOW}⏳ SDK Relay starting: WebSocket server not yet ready${NC}" fi fi echo fi } # Fonction pour afficher le statut des services show_services_status() { echo -e "${PURPLE}Services Status:${NC}" # Services critiques local services=("tor-proxy:Tor Proxy" "bitcoin-signet:Bitcoin Signet" "blindbit-oracle:BlindBit Oracle" "sdk_storage:SDK Storage" "sdk_relay:SDK Relay" "sdk_signer:SDK Signer" "ihm_client:IHM Client") for service in "${services[@]}"; do local container_name="${service%%:*}" local display_name="${service##*:}" local status=$(docker inspect --format='{{.State.Health.Status}}' "$container_name" 2>/dev/null || echo "no-healthcheck") local running=$(docker inspect --format='{{.State.Running}}' "$container_name" 2>/dev/null || echo "false") if [ "$running" = "true" ]; then case "$status" in "healthy") echo -e " ${GREEN}✓${NC} $display_name: ${GREEN}Ready${NC}" ;; "unhealthy") echo -e " ${YELLOW}⚠${NC} $display_name: ${YELLOW}Processing${NC}" ;; "starting") echo -e " ${YELLOW}⏳${NC} $display_name: ${YELLOW}Starting${NC}" ;; "no-healthcheck") echo -e " ${BLUE}ℹ${NC} $display_name: ${BLUE}Running${NC}" ;; esac else echo -e " ${RED}✗${NC} $display_name: ${RED}Stopped${NC}" fi done echo } # Fonction pour afficher les services en attente show_waiting_services() { echo -e "${PURPLE}Services Waiting for Dependencies:${NC}" # Vérifier les services LeCoffre local lecoffre_back=$(docker inspect --format='{{.State.Running}}' "lecoffre-back" 2>/dev/null || echo "false") local lecoffre_front=$(docker inspect --format='{{.State.Running}}' "lecoffre-front" 2>/dev/null || echo "false") if [ "$lecoffre_back" = "false" ]; then echo -e " ${YELLOW}⏳ LeCoffre Backend: Waiting for SDK Relay${NC}" fi if [ "$lecoffre_front" = "false" ]; then echo -e " ${YELLOW}⏳ LeCoffre Frontend: Waiting for LeCoffre Backend${NC}" fi echo } # Fonction principale main() { clear_and_header show_bitcoin_progress show_sdk_relay_progress show_services_status show_waiting_services echo -e "${BLUE}========================================${NC}" echo -e "${BLUE} Press Ctrl+C to stop monitoring${NC}" echo -e "${BLUE} Refresh every 10 seconds${NC}" echo -e "${BLUE}========================================${NC}" } # Fonction de nettoyage cleanup() { echo -e "\n${YELLOW}Monitoring stopped.${NC}" exit 0 } # Gestion des signaux trap cleanup SIGINT SIGTERM # Boucle principale while true; do main sleep 10 done