v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
174
scripts/start_vwb_backend_final_09jan2026.py
Executable file
174
scripts/start_vwb_backend_final_09jan2026.py
Executable file
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script de Démarrage Backend VWB - Version Finale
|
||||
Auteur : Dom, Alice, Kiro - 09 janvier 2026
|
||||
|
||||
Ce script démarre le backend Flask avec toutes les API connectées
|
||||
sur le port 5003 pour correspondre au frontend.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
# Ajouter le répertoire racine au path
|
||||
ROOT_DIR = Path(__file__).parent.parent
|
||||
sys.path.insert(0, str(ROOT_DIR))
|
||||
|
||||
def check_dependencies():
|
||||
"""Vérifier les dépendances critiques"""
|
||||
print("🔍 Vérification des dépendances...")
|
||||
|
||||
dependencies = [
|
||||
('flask', 'Flask'),
|
||||
('flask_cors', 'Flask-CORS'),
|
||||
('mss', 'MSS (capture d\'écran)'),
|
||||
('PIL', 'Pillow (traitement d\'images)'),
|
||||
('numpy', 'NumPy'),
|
||||
('requests', 'Requests'),
|
||||
]
|
||||
|
||||
missing = []
|
||||
|
||||
for module, name in dependencies:
|
||||
try:
|
||||
__import__(module)
|
||||
print(f"✅ {name}")
|
||||
except ImportError:
|
||||
print(f"❌ {name} - MANQUANT")
|
||||
missing.append(name)
|
||||
|
||||
if missing:
|
||||
print(f"\n⚠️ Dépendances manquantes: {', '.join(missing)}")
|
||||
print("Installez-les avec: pip install flask flask-cors mss pillow numpy requests")
|
||||
return False
|
||||
|
||||
print("✅ Toutes les dépendances sont présentes")
|
||||
return True
|
||||
|
||||
def check_port_availability(port):
|
||||
"""Vérifier si le port est disponible"""
|
||||
import socket
|
||||
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind(('localhost', port))
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
def start_backend():
|
||||
"""Démarrer le backend Flask"""
|
||||
print("🚀 Démarrage du backend VWB...")
|
||||
|
||||
# Définir les variables d'environnement
|
||||
env = os.environ.copy()
|
||||
env['PORT'] = '5003'
|
||||
env['FLASK_ENV'] = 'development'
|
||||
env['PYTHONPATH'] = str(ROOT_DIR)
|
||||
|
||||
# Chemin vers le script backend
|
||||
backend_script = ROOT_DIR / "visual_workflow_builder" / "backend" / "app_lightweight.py"
|
||||
|
||||
if not backend_script.exists():
|
||||
print(f"❌ Script backend non trouvé: {backend_script}")
|
||||
return False
|
||||
|
||||
# Vérifier la disponibilité du port
|
||||
if not check_port_availability(5003):
|
||||
print("⚠️ Le port 5003 est déjà utilisé")
|
||||
print("Tentative d'arrêt du processus existant...")
|
||||
|
||||
# Essayer de tuer le processus sur le port 5003
|
||||
try:
|
||||
subprocess.run(['pkill', '-f', 'app_lightweight.py'], check=False)
|
||||
time.sleep(2)
|
||||
|
||||
if check_port_availability(5003):
|
||||
print("✅ Port 5003 libéré")
|
||||
else:
|
||||
print("❌ Impossible de libérer le port 5003")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"⚠️ Erreur lors de la libération du port: {e}")
|
||||
|
||||
print(f"🌐 Démarrage sur http://localhost:5003")
|
||||
print(f"📁 Répertoire de travail: {ROOT_DIR}")
|
||||
print(f"🔧 Script: {backend_script}")
|
||||
print("")
|
||||
print("Endpoints disponibles:")
|
||||
print(" - GET /health - Santé de l'API")
|
||||
print(" - GET /api/workflows - Liste des workflows")
|
||||
print(" - POST /api/workflows - Créer un workflow")
|
||||
print(" - GET /api/workflows/<id> - Récupérer un workflow")
|
||||
print(" - PUT /api/workflows/<id> - Mettre à jour un workflow")
|
||||
print(" - DELETE /api/workflows/<id> - Supprimer un workflow")
|
||||
print(" - POST /api/screen-capture - Capturer l'écran (Option A)")
|
||||
print(" - POST /api/visual-embedding - Créer un embedding visuel")
|
||||
print(" - POST /api/workflow/execute - Exécuter un workflow")
|
||||
print(" - POST /api/workflow/execute-step - Exécuter une étape")
|
||||
print(" - POST /api/workflow/validate - Valider un workflow")
|
||||
print(" - GET /api/stats - Statistiques de l'API")
|
||||
print("")
|
||||
print("Appuyez sur Ctrl+C pour arrêter")
|
||||
print("=" * 60)
|
||||
|
||||
try:
|
||||
# Démarrer le backend
|
||||
process = subprocess.Popen(
|
||||
[sys.executable, str(backend_script)],
|
||||
env=env,
|
||||
cwd=str(ROOT_DIR),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
bufsize=1
|
||||
)
|
||||
|
||||
# Afficher la sortie en temps réel
|
||||
for line in process.stdout:
|
||||
print(line.rstrip())
|
||||
|
||||
return process.returncode == 0
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n🛑 Arrêt demandé par l'utilisateur")
|
||||
if 'process' in locals():
|
||||
process.terminate()
|
||||
process.wait()
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur lors du démarrage: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Fonction principale"""
|
||||
print("=" * 60)
|
||||
print(" DÉMARRAGE BACKEND VWB - VERSION FINALE")
|
||||
print("=" * 60)
|
||||
print("Auteur : Dom, Alice, Kiro - 09 janvier 2026")
|
||||
print("")
|
||||
|
||||
# Vérifier les dépendances
|
||||
if not check_dependencies():
|
||||
print("\n❌ Impossible de démarrer - dépendances manquantes")
|
||||
return False
|
||||
|
||||
print("")
|
||||
|
||||
# Démarrer le backend
|
||||
success = start_backend()
|
||||
|
||||
if success:
|
||||
print("\n✅ Backend arrêté proprement")
|
||||
else:
|
||||
print("\n❌ Erreur lors du démarrage du backend")
|
||||
|
||||
return success
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = main()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user