#!/bin/bash # Veza Full Stack Application Startup Script # Version: 1.0.0 set -e echo "🚀 DĂ©marrage de l'application Veza..." # Couleurs pour l'affichage RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Fonction pour afficher les messages 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" } # VĂ©rifier que Docker est installĂ© check_docker() { if ! command -v docker &> /dev/null; then print_error "Docker n'est pas installĂ©. Veuillez l'installer d'abord." exit 1 fi if ! command -v docker-compose &> /dev/null; then print_error "Docker Compose n'est pas installĂ©. Veuillez l'installer d'abord." exit 1 fi print_success "Docker et Docker Compose sont disponibles" } # ArrĂȘter tous les services existants stop_existing_services() { print_status "ArrĂȘt des services existants..." # ArrĂȘter les processus locaux pkill -f "server" || true pkill -f "vite" || true pkill -f "npm run dev" || true pkill -f "electron" || true # ArrĂȘter les conteneurs Docker docker-compose -f docker-compose.production.yml down || true docker-compose -f veza-backend-api/docker-compose.local.yml down || true print_success "Services arrĂȘtĂ©s" } # DĂ©marrer les services d'infrastructure start_infrastructure() { print_status "DĂ©marrage des services d'infrastructure..." # DĂ©marrer PostgreSQL et Redis docker-compose -f veza-backend-api/docker-compose.local.yml up -d postgres redis # Attendre que les services soient prĂȘts print_status "Attente du dĂ©marrage de PostgreSQL..." sleep 10 print_success "Infrastructure dĂ©marrĂ©e" } # DĂ©marrer le backend start_backend() { print_status "DĂ©marrage du backend API..." cd veza-backend-api ./server > ../logs/backend.log 2>&1 & BACKEND_PID=$! echo $BACKEND_PID > ../logs/backend.pid # Attendre que le backend soit prĂȘt sleep 5 # Tester le backend if curl -s http://localhost:8080/api/health > /dev/null; then print_success "Backend API dĂ©marrĂ© sur http://localhost:8080" else print_error "Le backend n'a pas dĂ©marrĂ© correctement" exit 1 fi cd .. } # DĂ©marrer le frontend start_frontend() { print_status "DĂ©marrage du frontend..." cd veza-frontend npm run dev > ../logs/frontend.log 2>&1 & FRONTEND_PID=$! echo $FRONTEND_PID > ../logs/frontend.pid # Attendre que le frontend soit prĂȘt sleep 10 # Tester le frontend if curl -s http://localhost:5176/ > /dev/null; then print_success "Frontend dĂ©marrĂ© sur http://localhost:5176" else print_warning "Le frontend n'est pas encore accessible" fi cd .. } # DĂ©marrer le chat server (si possible) start_chat_server() { print_status "Tentative de dĂ©marrage du chat server..." cd veza-chat-server # Essayer de dĂ©marrer le chat server make dev > ../logs/chat-server.log 2>&1 & CHAT_PID=$! echo $CHAT_PID > ../logs/chat-server.pid print_success "Chat server dĂ©marrĂ©" cd .. } # DĂ©marrer le desktop app start_desktop() { print_status "DĂ©marrage de l'application desktop..." cd veza-desktop # DĂ©marrer en mode dĂ©veloppement npm start > ../logs/desktop.log 2>&1 & DESKTOP_PID=$! echo $DESKTOP_PID > ../logs/desktop.pid print_success "Application desktop dĂ©marrĂ©e" cd .. } # CrĂ©er les rĂ©pertoires de logs create_log_dirs() { mkdir -p logs print_success "RĂ©pertoire de logs créé" } # Afficher le statut des services show_status() { echo "" echo "📊 Statut des services Veza:" echo "================================" # Backend if curl -s http://localhost:8080/api/health > /dev/null; then echo -e "✅ Backend API: http://localhost:8080" else echo -e "❌ Backend API: Non accessible" fi # Frontend if curl -s http://localhost:5176/ > /dev/null; then echo -e "✅ Frontend: http://localhost:5176" else echo -e "❌ Frontend: Non accessible" fi # PostgreSQL if docker ps | grep -q "veza-postgres-local"; then echo -e "✅ PostgreSQL: localhost:5432" else echo -e "❌ PostgreSQL: Non accessible" fi # Redis if docker ps | grep -q "veza-redis-local"; then echo -e "✅ Redis: localhost:6379" else echo -e "❌ Redis: Non accessible" fi # Chat Server if lsof -i :8081 > /dev/null 2>&1; then echo -e "✅ Chat Server: localhost:8081" else echo -e "🔄 Chat Server: En cours de configuration" fi echo "" echo "🎯 Application principale: http://localhost:5176" echo "đŸ“± Application desktop: LancĂ©e" echo "" } # Fonction principale main() { echo "đŸŽ” Veza Full Stack Application" echo "================================" # VĂ©rifications prĂ©alables check_docker # CrĂ©er les rĂ©pertoires nĂ©cessaires create_log_dirs # ArrĂȘter les services existants stop_existing_services # DĂ©marrer les services start_infrastructure start_backend start_frontend start_chat_server start_desktop # Afficher le statut final show_status echo "🎉 Application Veza dĂ©marrĂ©e avec succĂšs!" echo "" echo "📝 Commandes utiles:" echo " - ArrĂȘter: ./stop-veza.sh" echo " - Logs: tail -f logs/*.log" echo " - Docker: docker-compose -f docker-compose.production.yml up -d" echo "" } # ExĂ©cuter la fonction principale main "$@"