Added everything
This commit is contained in:
60
src/main.py
Normal file
60
src/main.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
Punto de entrada principal para VoxPopuli Microservices
|
||||
Ejecuta dos APIs en paralelo: Usuarios (puerto 8000) y Reportes (puerto 8001)
|
||||
"""
|
||||
from infrastructure.api.users.app import create_app as create_users_app
|
||||
from infrastructure.api.reports.app import create_app as create_reports_app
|
||||
from core.config import ConfSettings
|
||||
import threading
|
||||
import uvicorn
|
||||
|
||||
def run_users_api():
|
||||
"""Ejecuta la API de Usuarios en puerto 8000"""
|
||||
app_users = create_users_app()
|
||||
uvicorn.run(
|
||||
app_users,
|
||||
host=ConfSettings.host,
|
||||
port=8000,
|
||||
reload=False,
|
||||
log_level=ConfSettings.log_level,
|
||||
)
|
||||
|
||||
def run_reports_api():
|
||||
"""Ejecuta la API de Reportes en puerto 8001"""
|
||||
app_reports = create_reports_app()
|
||||
uvicorn.run(
|
||||
app_reports,
|
||||
host=ConfSettings.host,
|
||||
port=8001,
|
||||
reload=False,
|
||||
log_level=ConfSettings.log_level,
|
||||
)
|
||||
|
||||
def run():
|
||||
"""Inicia ambas APIs en threads separados"""
|
||||
print("=" * 60)
|
||||
print("Iniciando VoxPopuli Microservices...")
|
||||
print("=" * 60)
|
||||
|
||||
users_thread = threading.Thread(target=run_users_api, daemon=True, name="Users-API")
|
||||
reports_thread = threading.Thread(target=run_reports_api, daemon=True, name="Reports-API")
|
||||
|
||||
users_thread.start()
|
||||
reports_thread.start()
|
||||
|
||||
print("\n✓ API de Usuarios ejecutándose en http://0.0.0.0:8000")
|
||||
print("✓ API de Reportes ejecutándose en http://0.0.0.0:8001")
|
||||
print("\nDocumentación disponible en:")
|
||||
print(" - Usuarios: http://localhost:8000/docs")
|
||||
print(" - Reportes: http://localhost:8001/docs")
|
||||
print("\n" + "=" * 60 + "\n")
|
||||
|
||||
try:
|
||||
users_thread.join()
|
||||
reports_thread.join()
|
||||
except KeyboardInterrupt:
|
||||
print("\n\nRecibiendo señal de salida...")
|
||||
print("Cerrando APIs...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Reference in New Issue
Block a user