update submodule
This commit is contained in:
parent
2e822c2605
commit
3b0bc8b5c2
@ -25,8 +25,10 @@ wait_for_service() {
|
||||
local container_name="$2"
|
||||
local max_wait="${3:-300}" # 5 minutes par défaut
|
||||
local wait_time=0
|
||||
local last_progress_time=0
|
||||
local progress_interval=30 # Afficher la progression toutes les 30 secondes
|
||||
|
||||
print_message "Waiting for $service_name to be healthy..."
|
||||
print_message "Waiting for $service_name to be healthy (timeout: ${max_wait}s)..."
|
||||
|
||||
while [ $wait_time -lt $max_wait ]; do
|
||||
local status=$(docker inspect --format='{{.State.Health.Status}}' "$container_name" 2>/dev/null || echo "no-healthcheck")
|
||||
@ -40,8 +42,9 @@ wait_for_service() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Afficher la progression pour Tor
|
||||
# Afficher la progression pour Tor (timeout: 15 minutes)
|
||||
if [ "$service_name" = "Tor Proxy" ]; then
|
||||
if [ $((wait_time - last_progress_time)) -ge $progress_interval ]; then
|
||||
local bootstrap_log=$(docker logs "$container_name" --tail 20 2>/dev/null | grep "Bootstrapped" | tail -1 || echo "")
|
||||
if [ -n "$bootstrap_log" ]; then
|
||||
local progress=$(echo "$bootstrap_log" | grep -o '[0-9]\+%' | tail -1 || echo "0%")
|
||||
@ -49,15 +52,18 @@ wait_for_service() {
|
||||
print_message "${GREEN}✓ Tor ready: Bootstrap complete (100%)${NC}"
|
||||
return 0
|
||||
else
|
||||
print_message "${YELLOW}⏳ Tor bootstrapping: $progress${NC}"
|
||||
print_message "${YELLOW}⏳ Tor bootstrapping: $progress (${wait_time}s elapsed)${NC}"
|
||||
fi
|
||||
else
|
||||
print_message "${YELLOW}⏳ Tor starting: Bootstrap not yet started${NC}"
|
||||
print_message "${YELLOW}⏳ Tor starting: Bootstrap not yet started (${wait_time}s elapsed)${NC}"
|
||||
fi
|
||||
last_progress_time=$wait_time
|
||||
fi
|
||||
fi
|
||||
|
||||
# Afficher la progression pour Bitcoin
|
||||
# Afficher la progression pour Bitcoin (timeout: 2 heures)
|
||||
if [ "$service_name" = "Bitcoin Signet" ]; then
|
||||
if [ $((wait_time - last_progress_time)) -ge $progress_interval ]; then
|
||||
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')
|
||||
@ -71,12 +77,17 @@ wait_for_service() {
|
||||
print_message "${GREEN}✓ Bitcoin sync complete: $blocks blocks${NC}"
|
||||
return 0
|
||||
else
|
||||
print_message "${YELLOW}⏳ Bitcoin IBD: $blocks/$headers blocks ($(($headers - $blocks)) remaining) - $progress%${NC}"
|
||||
local remaining=$((headers - blocks))
|
||||
local elapsed_min=$((wait_time / 60))
|
||||
print_message "${YELLOW}⏳ Bitcoin IBD: $blocks/$headers blocks ($remaining remaining) - $progress% (${elapsed_min}min elapsed)${NC}"
|
||||
fi
|
||||
last_progress_time=$wait_time
|
||||
fi
|
||||
fi
|
||||
|
||||
# Afficher la progression pour BlindBit
|
||||
if [ "$service_name" = "BlindBit Oracle" ]; then
|
||||
if [ $((wait_time - last_progress_time)) -ge $progress_interval ]; then
|
||||
local response=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8000/tweaks/1 2>/dev/null || echo "000")
|
||||
case "$response" in
|
||||
"200")
|
||||
@ -84,28 +95,33 @@ wait_for_service() {
|
||||
return 0
|
||||
;;
|
||||
"000")
|
||||
print_message "${YELLOW}⏳ BlindBit starting: Oracle service not yet ready${NC}"
|
||||
print_message "${YELLOW}⏳ BlindBit starting: Oracle service not yet ready (${wait_time}s elapsed)${NC}"
|
||||
;;
|
||||
*)
|
||||
print_message "${YELLOW}⏳ BlindBit scanning: Oracle responding with code $response${NC}"
|
||||
print_message "${YELLOW}⏳ BlindBit scanning: Oracle responding with code $response (${wait_time}s elapsed)${NC}"
|
||||
;;
|
||||
esac
|
||||
last_progress_time=$wait_time
|
||||
fi
|
||||
fi
|
||||
|
||||
# Afficher la progression pour SDK Relay
|
||||
if [ "$service_name" = "SDK Relay" ]; then
|
||||
if [ $((wait_time - last_progress_time)) -ge $progress_interval ]; then
|
||||
local logs=$(docker logs "$container_name" --tail 3 2>/dev/null | grep -E "(waiting for|blocks to download|IBD)" | tail -1 || echo "")
|
||||
if [ -n "$logs" ]; then
|
||||
print_message "${YELLOW}⏳ SDK Relay IBD: $logs${NC}"
|
||||
print_message "${YELLOW}⏳ SDK Relay IBD: $logs (${wait_time}s elapsed)${NC}"
|
||||
else
|
||||
local response=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8091/ 2>/dev/null || echo "000")
|
||||
if [ "$response" = "200" ]; then
|
||||
print_message "${GREEN}✓ SDK Relay ready: WebSocket server responding${NC}"
|
||||
return 0
|
||||
else
|
||||
print_message "${YELLOW}⏳ SDK Relay starting: WebSocket server not yet ready${NC}"
|
||||
print_message "${YELLOW}⏳ SDK Relay starting: WebSocket server not yet ready (${wait_time}s elapsed)${NC}"
|
||||
fi
|
||||
fi
|
||||
last_progress_time=$wait_time
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
@ -153,21 +169,21 @@ main() {
|
||||
start_service "status-api"
|
||||
|
||||
# Attendre les services de base
|
||||
wait_for_service "Tor Proxy" "tor-proxy" 60
|
||||
wait_for_service "Tor Proxy" "tor-proxy" 900 # 15 minutes pour Tor bootstrap
|
||||
wait_for_service "SDK Storage" "sdk_storage" 120
|
||||
wait_for_service "SDK Signer" "sdk_signer" 120
|
||||
wait_for_service "SDK Signer" "sdk_signer" 300 # 5 minutes pour SDK Signer
|
||||
wait_for_service "Status API" "status-api" 60
|
||||
|
||||
# Phase 2: Services blockchain (séquentiel)
|
||||
print_message "${PURPLE}Phase 2: Starting blockchain services...${NC}"
|
||||
start_service "bitcoin"
|
||||
wait_for_service "Bitcoin Signet" "bitcoin-signet" 600 # 10 minutes pour Bitcoin
|
||||
wait_for_service "Bitcoin Signet" "bitcoin-signet" 7200 # 2 heures pour Bitcoin IBD
|
||||
|
||||
start_service "blindbit"
|
||||
wait_for_service "BlindBit Oracle" "blindbit-oracle" 300
|
||||
wait_for_service "BlindBit Oracle" "blindbit-oracle" 600 # 10 minutes pour BlindBit
|
||||
|
||||
start_service "sdk_relay"
|
||||
wait_for_service "SDK Relay" "sdk_relay" 600 # 10 minutes pour SDK Relay
|
||||
wait_for_service "SDK Relay" "sdk_relay" 1800 # 30 minutes pour SDK Relay IBD
|
||||
|
||||
# Phase 3: Services applicatifs (séquentiel)
|
||||
print_message "${PURPLE}Phase 3: Starting application services...${NC}"
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
# 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
|
||||
# Optimisé pour les processus longs (Tor: 15min, Bitcoin: 2h)
|
||||
|
||||
set -e
|
||||
|
||||
@ -14,6 +15,11 @@ PURPLE='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration des intervalles de mise à jour
|
||||
BITCOIN_UPDATE_INTERVAL=60 # Bitcoin: toutes les minutes
|
||||
TOR_UPDATE_INTERVAL=30 # Tor: toutes les 30 secondes
|
||||
OTHER_UPDATE_INTERVAL=15 # Autres services: toutes les 15 secondes
|
||||
|
||||
# Fonction pour effacer l'écran et afficher le header
|
||||
clear_and_header() {
|
||||
clear
|
||||
@ -41,7 +47,21 @@ show_bitcoin_progress() {
|
||||
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}"
|
||||
# Calculer le temps écoulé depuis le démarrage
|
||||
local start_time=$(docker inspect --format='{{.State.StartedAt}}' "$container_name" 2>/dev/null | xargs -I {} date -d {} +%s 2>/dev/null || echo "0")
|
||||
local current_time=$(date +%s)
|
||||
local elapsed_time=$((current_time - start_time))
|
||||
local elapsed_min=$((elapsed_time / 60))
|
||||
local elapsed_hour=$((elapsed_min / 60))
|
||||
|
||||
local time_str=""
|
||||
if [ $elapsed_hour -gt 0 ]; then
|
||||
time_str="${elapsed_hour}h ${elapsed_min}m"
|
||||
else
|
||||
time_str="${elapsed_min}m"
|
||||
fi
|
||||
|
||||
echo -e " ${YELLOW}⏳ Bitcoin IBD: $blocks/$headers blocks ($(($headers - $blocks)) remaining) - $progress% (${time_str} elapsed)${NC}"
|
||||
|
||||
# Afficher une barre de progression
|
||||
local bar_length=50
|
||||
@ -55,6 +75,26 @@ show_bitcoin_progress() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Fonction pour afficher la progression Tor
|
||||
show_tor_progress() {
|
||||
local container_name="tor-proxy"
|
||||
if docker ps --format "table {{.Names}}" | grep -q "$container_name"; then
|
||||
echo -e "${CYAN}Tor Progress:${NC}"
|
||||
local bootstrap_log=$(docker logs "$container_name" --tail 20 2>/dev/null | grep "Bootstrapped" | tail -1 || echo "")
|
||||
if [ -n "$bootstrap_log" ]; then
|
||||
local progress=$(echo "$bootstrap_log" | grep -o '[0-9]\+%' | tail -1 || echo "0%")
|
||||
if echo "$bootstrap_log" | grep -q "100%"; then
|
||||
echo -e " ${GREEN}✓ Tor ready: Bootstrap complete (100%)${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}⏳ Tor bootstrapping: $progress${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}⏳ Tor starting: Bootstrap not yet started${NC}"
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Fonction pour afficher la progression SDK Relay
|
||||
show_sdk_relay_progress() {
|
||||
local container_name="sdk_relay"
|
||||
@ -131,15 +171,38 @@ show_waiting_services() {
|
||||
|
||||
# Fonction principale
|
||||
main() {
|
||||
local current_time=$(date +%s)
|
||||
local bitcoin_should_update=$((current_time - last_bitcoin_update >= BITCOIN_UPDATE_INTERVAL))
|
||||
local tor_should_update=$((current_time - last_tor_update >= TOR_UPDATE_INTERVAL))
|
||||
local other_should_update=$((current_time - last_other_update >= OTHER_UPDATE_INTERVAL))
|
||||
|
||||
clear_and_header
|
||||
|
||||
# Afficher la progression Bitcoin (toutes les minutes)
|
||||
if [ $bitcoin_should_update -eq 1 ]; then
|
||||
show_bitcoin_progress
|
||||
last_bitcoin_update=$current_time
|
||||
fi
|
||||
|
||||
# Afficher la progression Tor (toutes les 30 secondes)
|
||||
if [ $tor_should_update -eq 1 ]; then
|
||||
show_tor_progress
|
||||
last_tor_update=$current_time
|
||||
fi
|
||||
|
||||
# Afficher la progression SDK Relay (toutes les 15 secondes)
|
||||
if [ $other_should_update -eq 1 ]; then
|
||||
show_sdk_relay_progress
|
||||
last_other_update=$current_time
|
||||
fi
|
||||
|
||||
# Toujours afficher le statut des services
|
||||
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} Bitcoin: ${BITCOIN_UPDATE_INTERVAL}s | Tor: ${TOR_UPDATE_INTERVAL}s | Others: ${OTHER_UPDATE_INTERVAL}s${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
}
|
||||
|
||||
@ -152,8 +215,13 @@ cleanup() {
|
||||
# Gestion des signaux
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Initialiser les timestamps
|
||||
last_bitcoin_update=0
|
||||
last_tor_update=0
|
||||
last_other_update=0
|
||||
|
||||
# Boucle principale
|
||||
while true; do
|
||||
main
|
||||
sleep 10
|
||||
sleep 15 # Rafraîchissement général toutes les 15 secondes
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user