from celery import Celery | |
from celery.schedules import crontab | |
import os | |
# Import the task function | |
from backend.celery_tasks.schedule_loader import load_schedules_task | |
# Create Celery instance for Beat scheduler | |
celery_beat = Celery('lin_scheduler') | |
# Configure Celery Beat | |
celery_beat.conf.broker_url = os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/0') | |
celery_beat.conf.result_backend = os.environ.get('CELERY_RESULT_BACKEND', 'redis://localhost:6379/0') | |
# Configure schedules | |
celery_beat.conf.beat_schedule = { | |
# This task will run every 5 minutes to load schedules from the database | |
'load-schedules': { | |
'task': 'backend.celery_tasks.schedule_loader.load_schedules_task', | |
'schedule': crontab(minute='*/5'), | |
}, | |
} | |
celery_beat.conf.timezone = 'UTC' |