55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import os
|
|
from celery import Celery
|
|
|
|
# Import models in correct order for SQLAlchemy relationship resolution
|
|
# CRITICAL: FaLineItem must be imported BEFORE LineItem
|
|
from api.v1.modules.a24.fa.fa_item_lines.models import FaLineItem # noqa: F401
|
|
from api.v1.modules.a76.items.models import LineItem # noqa: F401
|
|
|
|
valkey_url = os.getenv("VALKEY_URL", "redis://valkey:6379/0")
|
|
print(f"DEBUG: Celery Broker URL: {valkey_url}")
|
|
|
|
# Configurar broker y backend explícitamente en el constructor
|
|
celery_app = Celery(
|
|
"anexo76_tasks",
|
|
broker=valkey_url,
|
|
backend=valkey_url,
|
|
)
|
|
celery_app.set_default()
|
|
|
|
celery_app.conf.update(
|
|
include=[
|
|
"api.v1.modules.a76.reports.importacion.facturas.task",
|
|
"api.v1.modules.a76.reports.importacion.consolidados.task",
|
|
"api.v1.modules.a76.reports.importacion.packing_list.task",
|
|
"api.v1.modules.a76.reports.exportacion.aviso_consolidado.task",
|
|
"api.v1.modules.a76.reports.movements.invoices.tasks",
|
|
"api.v1.modules.a76.reports.exportacion.descargo.task",
|
|
"api.v1.modules.a76.imports.tasks",
|
|
"api.v1.modules.a76.reports.exportacion.transmission.MAINX30.task",
|
|
"api.v1.modules.a76.reports.importacion.transmission.temporal.MAINX30.task",
|
|
"api.v1.modules.a76.reports.importacion.transmission.definitive.MAINX30.task",
|
|
"api.v1.modules.core.help_center.tasks"
|
|
] # Ruta al módulo donde están las tareas
|
|
)
|
|
|
|
# Configuraciones adicionales
|
|
celery_app.conf.update(
|
|
task_track_started=True,
|
|
task_serializer="json",
|
|
accept_content=["json"],
|
|
result_serializer="json",
|
|
timezone="America/Mexico_City",
|
|
enable_utc=True,
|
|
)
|
|
|
|
celery_app.conf.beat_schedule = {
|
|
"sync-from-hub-every-minute": {
|
|
"task": "sync_from_hub_task",
|
|
"schedule": 60.0, # Run every 60 seconds
|
|
},
|
|
}
|
|
|
|
if __name__ == "__main__":
|
|
celery_app.start()
|