Initial commit
This commit is contained in:
158
start_with_info.py
Executable file
158
start_with_info.py
Executable file
@@ -0,0 +1,158 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script mejorado para iniciar el servicio completo con mejor información
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
# Añadir path
|
||||
sys.path.append('/home/ren/cbc')
|
||||
|
||||
def print_banner():
|
||||
"""Muestra banner de inicio"""
|
||||
print("\n" + "=" * 70)
|
||||
print("🚀 NEXTCLOUD AI SERVICE - DASHBOARD INTEGRADO")
|
||||
print("=" * 70)
|
||||
print()
|
||||
|
||||
def print_step(step, message):
|
||||
"""Imprime un paso con formato"""
|
||||
print(f" [{step}] {message}")
|
||||
|
||||
def check_dependencies():
|
||||
"""Verifica dependencias"""
|
||||
print_step("1", "Verificando dependencias...")
|
||||
|
||||
try:
|
||||
import flask
|
||||
print_step(" ✓", f"Flask {flask.__version__}")
|
||||
except ImportError:
|
||||
print_step(" ✗", "Flask no está instalado")
|
||||
print("\n 💡 Instalar: pip3 install flask flask-cors")
|
||||
return False
|
||||
|
||||
try:
|
||||
import flask_cors
|
||||
print_step(" ✓", "Flask-CORS")
|
||||
except ImportError:
|
||||
print_step(" ✗", "Flask-CORS no está instalado")
|
||||
print("\n 💡 Instalar: pip3 install flask-cors")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def check_dashboard():
|
||||
"""Verifica dashboard"""
|
||||
print_step("2", "Verificando dashboard...")
|
||||
|
||||
try:
|
||||
import dashboard
|
||||
print_step(" ✓", "Dashboard importado correctamente")
|
||||
return True
|
||||
except Exception as e:
|
||||
print_step(" ✗", f"Error importando dashboard: {e}")
|
||||
return False
|
||||
|
||||
def check_main():
|
||||
"""Verifica main.py"""
|
||||
print_step("3", "Verificando servicio principal...")
|
||||
|
||||
try:
|
||||
import main
|
||||
print_step(" ✓", "Servicio principal importado")
|
||||
return True
|
||||
except Exception as e:
|
||||
print_step(" ✗", f"Error importando servicio principal: {e}")
|
||||
return False
|
||||
|
||||
def start_dashboard():
|
||||
"""Inicia dashboard en hilo separado"""
|
||||
print_step("4", "Iniciando dashboard en hilo separado...")
|
||||
|
||||
try:
|
||||
import dashboard
|
||||
import threading
|
||||
|
||||
def run_dashboard():
|
||||
"""Función para ejecutar dashboard"""
|
||||
print("\n 🌐 Iniciando servidor Flask...")
|
||||
dashboard.app.run(
|
||||
host='0.0.0.0',
|
||||
port=5000,
|
||||
debug=False,
|
||||
threaded=True,
|
||||
use_reloader=False
|
||||
)
|
||||
|
||||
# Crear hilo
|
||||
dashboard_thread = threading.Thread(target=run_dashboard, daemon=True)
|
||||
dashboard_thread.start()
|
||||
|
||||
# Dar tiempo para que inicie
|
||||
time.sleep(2)
|
||||
|
||||
print_step(" ✓", "Dashboard iniciado")
|
||||
print("\n 📱 Dashboard disponible en:")
|
||||
print(" http://localhost:5000")
|
||||
print()
|
||||
|
||||
return dashboard_thread
|
||||
|
||||
except Exception as e:
|
||||
print_step(" ✗", f"Error iniciando dashboard: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return None
|
||||
|
||||
def start_main_service():
|
||||
"""Inicia servicio principal"""
|
||||
print_step("5", "Iniciando servicio principal...")
|
||||
|
||||
try:
|
||||
import main
|
||||
|
||||
print("\n ⏳ Iniciando bucle principal...")
|
||||
print(" 📊 El servicio procesará archivos automáticamente")
|
||||
print(" ⏹️ Para detener: Ctrl+C")
|
||||
print()
|
||||
print("=" * 70)
|
||||
|
||||
# Iniciar servicio
|
||||
main.main()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n\n🛑 Servicio detenido por el usuario")
|
||||
except Exception as e:
|
||||
print(f"\n\n❌ Error en servicio principal: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def main():
|
||||
"""Función principal"""
|
||||
print_banner()
|
||||
|
||||
# Verificar todo
|
||||
if not check_dependencies():
|
||||
sys.exit(1)
|
||||
|
||||
if not check_dashboard():
|
||||
sys.exit(1)
|
||||
|
||||
if not check_main():
|
||||
sys.exit(1)
|
||||
|
||||
# Iniciar dashboard
|
||||
dashboard_thread = start_dashboard()
|
||||
if not dashboard_thread:
|
||||
print("\n⚠️ Continuando sin dashboard...")
|
||||
|
||||
# Iniciar servicio principal
|
||||
start_main_service()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user