#!/bin/bash # đŸŽ” Veza Platform - Script de dĂ©marrage complet # Version 2.0.0 set -e # Couleurs pour les messages 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 # Configuration BACKEND_PORT=8080 FRONTEND_PORT=5173 DESKTOP_PORT=5177 echo -e "${PURPLE}đŸŽ” Veza Platform - DĂ©marrage complet${NC}" echo -e "${CYAN}================================${NC}" echo "" # Fonction pour vĂ©rifier si un port est utilisĂ© check_port() { local port=$1 if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null ; then echo -e "${YELLOW}⚠ Le port $port est dĂ©jĂ  utilisĂ©${NC}" return 1 fi return 0 } # Fonction pour arrĂȘter les processus existants cleanup() { echo -e "${YELLOW}đŸ§č Nettoyage des processus existants...${NC}" pkill -f "go run.*simple-server" 2>/dev/null || true pkill -f "vite" 2>/dev/null || true pkill -f "electron" 2>/dev/null || true sleep 2 } # Fonction pour vĂ©rifier les dĂ©pendances check_dependencies() { echo -e "${BLUE}🔍 VĂ©rification des dĂ©pendances...${NC}" # VĂ©rifier Go if ! command -v go &> /dev/null; then echo -e "${RED}❌ Go n'est pas installĂ©${NC}" exit 1 fi # VĂ©rifier Node.js if ! command -v node &> /dev/null; then echo -e "${RED}❌ Node.js n'est pas installĂ©${NC}" exit 1 fi # VĂ©rifier npm if ! command -v npm &> /dev/null; then echo -e "${RED}❌ npm n'est pas installĂ©${NC}" exit 1 fi echo -e "${GREEN}✅ Toutes les dĂ©pendances sont installĂ©es${NC}" } # Fonction pour dĂ©marrer le backend start_backend() { echo -e "${BLUE}🚀 DĂ©marrage du Backend API...${NC}" if ! check_port $BACKEND_PORT; then echo -e "${YELLOW}⚠ Tentative d'arrĂȘt du processus sur le port $BACKEND_PORT${NC}" lsof -ti:$BACKEND_PORT | xargs kill -9 2>/dev/null || true sleep 2 fi cd veza-backend-api nohup go run simple-server.go > ../logs/backend.log 2>&1 & BACKEND_PID=$! echo $BACKEND_PID > ../logs/backend.pid # Attendre que le backend dĂ©marre echo -e "${YELLOW}⏳ Attente du dĂ©marrage du backend...${NC}" for i in {1..30}; do if curl -s http://localhost:$BACKEND_PORT/health > /dev/null 2>&1; then echo -e "${GREEN}✅ Backend API dĂ©marrĂ© sur http://localhost:$BACKEND_PORT${NC}" break fi if [ $i -eq 30 ]; then echo -e "${RED}❌ Échec du dĂ©marrage du backend${NC}" exit 1 fi sleep 1 done cd .. } # Fonction pour dĂ©marrer le frontend start_frontend() { echo -e "${BLUE}🌐 DĂ©marrage du Frontend...${NC}" if ! check_port $FRONTEND_PORT; then echo -e "${YELLOW}⚠ Tentative d'arrĂȘt du processus sur le port $FRONTEND_PORT${NC}" lsof -ti:$FRONTEND_PORT | xargs kill -9 2>/dev/null || true sleep 2 fi cd veza-frontend # Installer les dĂ©pendances si nĂ©cessaire if [ ! -d "node_modules" ]; then echo -e "${YELLOW}📩 Installation des dĂ©pendances frontend...${NC}" npm install fi nohup npm run dev > ../logs/frontend.log 2>&1 & FRONTEND_PID=$! echo $FRONTEND_PID > ../logs/frontend.pid # Attendre que le frontend dĂ©marre echo -e "${YELLOW}⏳ Attente du dĂ©marrage du frontend...${NC}" for i in {1..30}; do if curl -s http://localhost:$FRONTEND_PORT > /dev/null 2>&1; then echo -e "${GREEN}✅ Frontend dĂ©marrĂ© sur http://localhost:$FRONTEND_PORT${NC}" break fi if [ $i -eq 30 ]; then echo -e "${RED}❌ Échec du dĂ©marrage du frontend${NC}" exit 1 fi sleep 1 done cd .. } # Fonction pour dĂ©marrer l'application desktop start_desktop() { echo -e "${BLUE}đŸ–„ïž DĂ©marrage de l'application Desktop...${NC}" cd veza-desktop # Installer les dĂ©pendances si nĂ©cessaire if [ ! -d "node_modules" ]; then echo -e "${YELLOW}📩 Installation des dĂ©pendances desktop...${NC}" npm install fi # DĂ©marrer l'application desktop nohup npm start > ../logs/desktop.log 2>&1 & DESKTOP_PID=$! echo $DESKTOP_PID > ../logs/desktop.pid echo -e "${GREEN}✅ Application Desktop dĂ©marrĂ©e${NC}" cd .. } # Fonction pour afficher le statut show_status() { echo "" echo -e "${PURPLE}📊 Statut des services:${NC}" echo -e "${CYAN}================================${NC}" # Backend if curl -s http://localhost:$BACKEND_PORT/health > /dev/null 2>&1; then echo -e "${GREEN}✅ Backend API: http://localhost:$BACKEND_PORT${NC}" else echo -e "${RED}❌ Backend API: Non disponible${NC}" fi # Frontend if curl -s http://localhost:$FRONTEND_PORT > /dev/null 2>&1; then echo -e "${GREEN}✅ Frontend Web: http://localhost:$FRONTEND_PORT${NC}" else echo -e "${RED}❌ Frontend Web: Non disponible${NC}" fi # Desktop if [ -f "logs/desktop.pid" ] && ps -p $(cat logs/desktop.pid) > /dev/null 2>&1; then echo -e "${GREEN}✅ Application Desktop: En cours d'exĂ©cution${NC}" else echo -e "${YELLOW}⚠ Application Desktop: Non dĂ©marrĂ©e${NC}" fi echo "" echo -e "${PURPLE}🎯 URLs d'accĂšs:${NC}" echo -e "${CYAN}================================${NC}" echo -e "${BLUE}🌐 Application Web:${NC} http://localhost:$FRONTEND_PORT" echo -e "${BLUE}🔌 API Backend:${NC} http://localhost:$BACKEND_PORT" echo -e "${BLUE}📊 Health Check:${NC} http://localhost:$BACKEND_PORT/health" echo "" echo -e "${GREEN}🎉 Veza Platform est prĂȘt !${NC}" echo -e "${YELLOW}💡 Utilisez Ctrl+C pour arrĂȘter tous les services${NC}" } # Fonction de nettoyage Ă  la sortie cleanup_on_exit() { echo "" echo -e "${YELLOW}🔄 ArrĂȘt des services...${NC}" # ArrĂȘter les processus if [ -f "logs/backend.pid" ]; then kill $(cat logs/backend.pid) 2>/dev/null || true rm -f logs/backend.pid fi if [ -f "logs/frontend.pid" ]; then kill $(cat logs/frontend.pid) 2>/dev/null || true rm -f logs/frontend.pid fi if [ -f "logs/desktop.pid" ]; then kill $(cat logs/desktop.pid) 2>/dev/null || true rm -f logs/desktop.pid fi echo -e "${GREEN}✅ Services arrĂȘtĂ©s${NC}" exit 0 } # Configuration du trap pour le nettoyage trap cleanup_on_exit INT TERM # CrĂ©er le dossier logs s'il n'existe pas mkdir -p logs # DĂ©marrage principal main() { echo -e "${PURPLE}đŸŽ” Veza Platform - DĂ©marrage complet${NC}" echo -e "${CYAN}================================${NC}" echo "" # VĂ©rifier les dĂ©pendances check_dependencies # Nettoyer les processus existants cleanup # DĂ©marrer les services start_backend start_frontend start_desktop # Afficher le statut show_status # Attendre indĂ©finiment while true; do sleep 10 done } # ExĂ©cuter le script principal main "$@"