#!/bin/bash echo "🚀 Iniciando todos os microserviços..." echo "" # Diretório base BASE_DIR="$(pwd)" # Função para verificar se a porta está em uso check_port() { lsof -ti:$1 > /dev/null 2>&1 return $? } # Função para iniciar serviço start_service() { local name=$1 local dir=$2 local port=$3 echo "Starting $name on port $port..." # Verificar se porta está em uso if check_port $port; then echo " ⚠️ Port $port already in use, skipping $name" return fi cd "$BASE_DIR/$dir" # Instalar dependências se necessário if [ ! -d "venv" ]; then python3 -m venv venv source venv/bin/activate pip install -q -r requirements.txt deactivate fi # Iniciar serviço source venv/bin/activate nohup python3 *.py > /tmp/$name.log 2>&1 & local PID=$! deactivate echo " ✅ $name started (PID: $PID)" sleep 1 } # Iniciar serviços echo "1️⃣ Starting Whisper Service..." start_service "whisper" "services/whisper" 5001 echo "2️⃣ Starting LLM Service..." start_service "llm" "services/llm" 5002 echo "3️⃣ Starting TTS Service..." start_service "tts" "services/tts" 5003 echo "4️⃣ Starting MuseTalk Service..." start_service "musetalk" "services/musetalk" 5004 echo "5️⃣ Starting Gateway..." start_service "gateway" "gateway" 8080 echo "" echo "✅ All services started!" echo "" echo "📊 Service URLs:" echo " Whisper: http://localhost:5001" echo " LLM: http://localhost:5002" echo " TTS: http://localhost:5003" echo " MuseTalk: http://localhost:5004" echo " Gateway: http://localhost:8080" echo "" echo "🧪 Run tests:" echo " python3 test_latency.py" echo "" echo "🛑 Stop all services:" echo " ./stop-all.sh"