I'm kinda dumb and fought with this thing instead of just instancing the consumers directly
This commit is contained in:
16
src/main.py
16
src/main.py
@@ -4,6 +4,8 @@ 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.users.app import create_app as create_users_app
|
||||||
from infrastructure.api.reports.app import create_app as create_reports_app
|
from infrastructure.api.reports.app import create_app as create_reports_app
|
||||||
|
from consumers.report_consumer import ReportConsumer
|
||||||
|
from consumers.user_consumer import UserConsumer
|
||||||
from core.config import ConfSettings
|
from core.config import ConfSettings
|
||||||
import threading
|
import threading
|
||||||
import uvicorn
|
import uvicorn
|
||||||
@@ -30,6 +32,15 @@ def run_reports_api():
|
|||||||
log_level=ConfSettings.log_level,
|
log_level=ConfSettings.log_level,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def run_user_consumer():
|
||||||
|
consumer = UserConsumer()
|
||||||
|
consumer.start()
|
||||||
|
|
||||||
|
def run_reports_consumer():
|
||||||
|
consumer = ReportConsumer()
|
||||||
|
consumer.start()
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""Inicia ambas APIs en threads separados"""
|
"""Inicia ambas APIs en threads separados"""
|
||||||
print("=" * 60)
|
print("=" * 60)
|
||||||
@@ -38,9 +49,14 @@ def run():
|
|||||||
|
|
||||||
users_thread = threading.Thread(target=run_users_api, daemon=True, name="Users-API")
|
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")
|
reports_thread = threading.Thread(target=run_reports_api, daemon=True, name="Reports-API")
|
||||||
|
user_consumer_thread = threading.Thread(target=run_user_consumer, daemon=True, name="Users-Consumer")
|
||||||
|
report_consumer_thread = threading.Thread(target=run_reports_consumer, daemon=True, name="Reports-Consumer")
|
||||||
|
|
||||||
|
|
||||||
users_thread.start()
|
users_thread.start()
|
||||||
reports_thread.start()
|
reports_thread.start()
|
||||||
|
user_consumer_thread.start()
|
||||||
|
report_consumer_thread.start()
|
||||||
|
|
||||||
print("\n✓ API de Usuarios ejecutándose en http://0.0.0.0:8000")
|
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("✓ API de Reportes ejecutándose en http://0.0.0.0:8001")
|
||||||
|
|||||||
Reference in New Issue
Block a user