ci: docker_tag=ext - Add start-monitoring.sh script and update deployment architecture

- Create start-monitoring.sh for independent monitoring services startup
- Update start-with-progress.sh with 5-phase deployment architecture
- Fix docker-compose.yml dependencies syntax for proper service ordering
- Implement Loki → Promtail → Grafana sequential startup
- Add proper healthcheck dependencies between monitoring services
- Separate application services from monitoring services
- Optimize startup order: base services (parallel) → blockchain (sequential) → apps (sequential) → monitoring (independent) → utils
This commit is contained in:
Nicolas Cantu 2025-09-21 22:36:32 +00:00
parent 2b1cf9f406
commit 0ee0505ce5
2 changed files with 132 additions and 23 deletions

111
scripts/start-monitoring.sh Executable file
View File

@ -0,0 +1,111 @@
#!/bin/bash
# Script de démarrage des services de monitoring LeCoffre Node
# Démarre les services de monitoring dans l'ordre correct et indépendant
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 afficher un message
print_message() {
echo -e "${BLUE}[$(date '+%H:%M:%S')]${NC} $1"
}
# Fonction pour attendre qu'un service soit healthy
wait_for_service() {
local service_name="$1"
local container_name="$2"
local max_wait="${3:-120}" # 2 minutes par défaut
local wait_time=0
print_message "Waiting for $service_name to be healthy..."
while [ $wait_time -lt $max_wait ]; do
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" ] && [ "$status" = "healthy" ]; then
print_message "${GREEN}$service_name is healthy${NC}"
return 0
elif [ "$running" = "false" ]; then
print_message "${RED}$service_name is not running${NC}"
return 1
fi
sleep 10
wait_time=$((wait_time + 10))
done
print_message "${RED}✗ Timeout waiting for $service_name${NC}"
return 1
}
# Fonction pour démarrer un service
start_service() {
local service_name="$1"
print_message "Starting $service_name..."
if docker compose --env-file .env.master up -d "$service_name"; then
print_message "${GREEN}$service_name started${NC}"
return 0
else
print_message "${RED}✗ Failed to start $service_name${NC}"
return 1
fi
}
# Fonction principale
main() {
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} LeCoffre Node - Monitoring Services${NC}"
echo -e "${BLUE}========================================${NC}"
echo
# Arrêter les services de monitoring existants
print_message "Stopping existing monitoring services..."
docker compose --env-file .env.master stop loki promtail grafana 2>/dev/null || true
docker compose --env-file .env.master rm -f loki promtail grafana 2>/dev/null || true
# Démarrer les services de monitoring dans l'ordre correct
print_message "${PURPLE}Starting monitoring services in correct order...${NC}"
echo
# 1. Loki (base de données de logs)
print_message "${CYAN}Step 1: Starting Loki (log database)...${NC}"
start_service "loki"
wait_for_service "Loki" "loki" 120
# 2. Promtail (collecte des logs)
print_message "${CYAN}Step 2: Starting Promtail (log collection)...${NC}"
start_service "promtail"
wait_for_service "Promtail" "promtail" 60
# 3. Grafana (visualisation)
print_message "${CYAN}Step 3: Starting Grafana (visualization)...${NC}"
start_service "grafana"
wait_for_service "Grafana" "grafana" 120
echo
print_message "${GREEN}✓ All monitoring services started successfully!${NC}"
echo
print_message "Monitoring URLs:"
print_message " - Grafana: https://dev4.4nkweb.com/grafana/"
print_message " - Loki API: https://dev4.4nkweb.com/loki/"
print_message " - Status: https://dev4.4nkweb.com/status/"
echo
print_message "Use './scripts/monitor-progress.sh' to monitor all services"
print_message "Use './scripts/watch-progress.sh' for real-time monitoring"
echo
print_message "${GREEN}Monitoring startup complete!${NC}"
}
# Exécution
main "$@"

View File

@ -129,43 +129,42 @@ main() {
print_message "Starting services in correct order..." print_message "Starting services in correct order..."
echo echo
# 1. Tor # Phase 1: Services de base (parallèle)
print_message "${PURPLE}Phase 1: Starting base services...${NC}"
start_service "tor" start_service "tor"
start_service "sdk_storage"
start_service "sdk_signer"
start_service "status-api"
# Attendre les services de base
wait_for_service "Tor Proxy" "tor-proxy" 60 wait_for_service "Tor Proxy" "tor-proxy" 60
wait_for_service "SDK Storage" "sdk_storage" 120
wait_for_service "SDK Signer" "sdk_signer" 120
wait_for_service "Status API" "status-api" 60
# 2. Bitcoin # Phase 2: Services blockchain (séquentiel)
print_message "${PURPLE}Phase 2: Starting blockchain services...${NC}"
start_service "bitcoin" start_service "bitcoin"
wait_for_service "Bitcoin Signet" "bitcoin-signet" 600 # 10 minutes pour Bitcoin wait_for_service "Bitcoin Signet" "bitcoin-signet" 600 # 10 minutes pour Bitcoin
# 3. BlindBit
start_service "blindbit" start_service "blindbit"
wait_for_service "BlindBit Oracle" "blindbit-oracle" 300 wait_for_service "BlindBit Oracle" "blindbit-oracle" 300
# 4. SDK Storage
start_service "sdk_storage"
wait_for_service "SDK Storage" "sdk_storage" 120
# 5. SDK Relay
start_service "sdk_relay" start_service "sdk_relay"
wait_for_service "SDK Relay" "sdk_relay" 600 # 10 minutes pour SDK Relay wait_for_service "SDK Relay" "sdk_relay" 600 # 10 minutes pour SDK Relay
# 6. SDK Signer # Phase 3: Services applicatifs (séquentiel)
start_service "sdk_signer" print_message "${PURPLE}Phase 3: Starting application services...${NC}"
wait_for_service "SDK Signer" "sdk_signer" 120
# 7. IHM Client
start_service "ihm_client"
wait_for_service "IHM Client" "ihm_client" 120
# 8. LeCoffre Backend
start_service "lecoffre-back" start_service "lecoffre-back"
wait_for_service "LeCoffre Backend" "lecoffre-back" 120 wait_for_service "LeCoffre Backend" "lecoffre-back" 120
# 9. LeCoffre Frontend
start_service "lecoffre-front" start_service "lecoffre-front"
start_service "ihm_client"
wait_for_service "LeCoffre Frontend" "lecoffre-front" 120 wait_for_service "LeCoffre Frontend" "lecoffre-front" 120
wait_for_service "IHM Client" "ihm_client" 120
# 10. Services de monitoring (ordre correct) # Phase 4: Services de monitoring (séquentiel, indépendant)
print_message "${PURPLE}Phase 4: Starting monitoring services...${NC}"
start_service "loki" start_service "loki"
wait_for_service "Loki" "loki" 120 wait_for_service "Loki" "loki" 120
@ -174,10 +173,9 @@ main() {
start_service "grafana" start_service "grafana"
wait_for_service "Grafana" "grafana" 120 wait_for_service "Grafana" "grafana" 120
start_service "status-api" # Phase 5: Services utilitaires
wait_for_service "Status API" "status-api" 60 print_message "${PURPLE}Phase 5: Starting utility services...${NC}"
start_service "watchtower" start_service "watchtower"
echo echo