#!/bin/bash echo "🛑 ArrĂȘt du SystĂšme Notarial 4NK" echo "=================================" echo # Couleurs pour les messages RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color print_status() { echo -e "${BLUE}[INFO]${NC} $1" } print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } # ArrĂȘt de l'API stop_api() { print_status "ArrĂȘt de l'API Notariale..." if [ -f "logs/api.pid" ]; then API_PID=$(cat logs/api.pid) if kill -0 $API_PID 2>/dev/null; then kill $API_PID print_success "API arrĂȘtĂ©e (PID: $API_PID)" else print_warning "API dĂ©jĂ  arrĂȘtĂ©e" fi rm -f logs/api.pid else print_warning "Fichier PID de l'API non trouvĂ©" fi } # ArrĂȘt de l'interface web stop_web_interface() { print_status "ArrĂȘt de l'interface web..." if [ -f "logs/web.pid" ]; then WEB_PID=$(cat logs/web.pid) if kill -0 $WEB_PID 2>/dev/null; then kill $WEB_PID print_success "Interface web arrĂȘtĂ©e (PID: $WEB_PID)" else print_warning "Interface web dĂ©jĂ  arrĂȘtĂ©e" fi rm -f logs/web.pid else print_warning "Fichier PID de l'interface web non trouvĂ©" fi } # ArrĂȘt des services Docker stop_docker_services() { print_status "ArrĂȘt des services Docker..." cd infra # ArrĂȘt des services docker-compose down print_success "Services Docker arrĂȘtĂ©s" cd .. } # Nettoyage des processus orphelins cleanup_orphaned_processes() { print_status "Nettoyage des processus orphelins..." # Recherche et arrĂȘt des processus uvicorn UVICORN_PIDS=$(pgrep -f "uvicorn.*app:app") if [ ! -z "$UVICORN_PIDS" ]; then echo $UVICORN_PIDS | xargs kill print_success "Processus uvicorn orphelins arrĂȘtĂ©s" fi # Recherche et arrĂȘt des processus Python de l'interface web WEB_PIDS=$(pgrep -f "start_web.py") if [ ! -z "$WEB_PIDS" ]; then echo $WEB_PIDS | xargs kill print_success "Processus interface web orphelins arrĂȘtĂ©s" fi } # Affichage du statut final show_final_status() { echo echo "✅ SystĂšme Notarial 4NK arrĂȘtĂ©" echo "===============================" echo echo "📊 Statut des services:" # VĂ©rification de l'API if curl -s http://localhost:8000/api/health &> /dev/null; then echo " ‱ API: ${RED}Encore actif${NC}" else echo " ‱ API: ${GREEN}ArrĂȘtĂ©${NC}" fi # VĂ©rification de l'interface web if curl -s http://localhost:8080 &> /dev/null; then echo " ‱ Interface Web: ${RED}Encore actif${NC}" else echo " ‱ Interface Web: ${GREEN}ArrĂȘtĂ©${NC}" fi # VĂ©rification des services Docker cd infra if docker-compose ps | grep -q "Up"; then echo " ‱ Services Docker: ${RED}Encore actifs${NC}" else echo " ‱ Services Docker: ${GREEN}ArrĂȘtĂ©s${NC}" fi cd .. echo echo "🔧 Pour redĂ©marrer: ./start_notary_system.sh" echo } # Fonction principale main() { echo "ArrĂȘt du systĂšme Ă  $(date)" echo # ArrĂȘt de l'API stop_api # ArrĂȘt de l'interface web stop_web_interface # ArrĂȘt des services Docker stop_docker_services # Nettoyage des processus orphelins cleanup_orphaned_processes # Attente pour que les processus se terminent sleep 2 # Affichage du statut final show_final_status } # ExĂ©cution du script principal main "$@"