- 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
112 lines
3.6 KiB
Bash
Executable File
112 lines
3.6 KiB
Bash
Executable File
#!/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 "$@"
|