The only thing this doesnt handle is when a client goes into offline due to a transient link failure but it comes back online. We want to avoid updating the DB every time a pong is RX'd.. Perhaps we do a seocndary corss checks with offline hosts?
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""
|
|
celery_factory.py -- Re-export the canonical Celery instance.
|
|
|
|
This file used to create a *second* Celery app. Since `app/__init__.py`
|
|
now owns the one-and-only `celery_app`, we simply import and expose it
|
|
here so legacy imports (`from app.celery_factory import celery`) keep
|
|
working.
|
|
|
|
If you want per-project beat schedules, append them to `celery_app.conf`
|
|
after import.
|
|
"""
|
|
|
|
from logging import getLogger
|
|
|
|
from app import celery_app as celery # ← single source-of-truth
|
|
from app import app as flask_app # access to config & logger
|
|
|
|
log = getLogger("xcloudify.celery_factory")
|
|
log.info("Using existing Celery instance from app.__init__")
|
|
|
|
# ───────────────────────── Optional: add beat jobs ────────────────────
|
|
celery.conf.beat_schedule.update(
|
|
{
|
|
"heartbeat-30s": {
|
|
"task": "tasks.log_heartbeat",
|
|
"schedule": 30.0,
|
|
},
|
|
"reconcile_online_workers-30s": {
|
|
"task": "tasks.reconcile_online_workers",
|
|
"schedule": 2.0,
|
|
},
|
|
# Add more periodic jobs here if desired
|
|
# "collect-system-metrics": {
|
|
# "task": "tasks.collect_system_metrics",
|
|
# "schedule": timedelta(minutes=1),
|
|
# },
|
|
}
|
|
)
|
|
|
|
# The export below keeps your old import paths valid:
|
|
__all__ = ["celery"]
|
|
import app.tasks.process_workload_request
|
|
import app.tasks.simple
|
|
import app.tasks.reconcile_online_workers |