243 lines
No EOL
5.8 KiB
Bash
Executable file
243 lines
No EOL
5.8 KiB
Bash
Executable file
#!/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 "$@" |