""" Celery application configuration. """ from celery import Celery from celery.schedules import crontab from app.core.config import settings # Create Celery app celery_app = Celery( "social_automation", broker=settings.REDIS_URL, backend=settings.REDIS_URL, include=[ "app.worker.tasks", ] ) # Celery configuration celery_app.conf.update( # Serialization task_serializer="json", accept_content=["json"], result_serializer="json", # Timezone timezone="America/Tijuana", enable_utc=True, # Task settings task_track_started=True, task_time_limit=300, # 5 minutes max per task task_soft_time_limit=240, # Soft limit 4 minutes # Result backend settings result_expires=86400, # Results expire after 24 hours # Worker settings worker_prefetch_multiplier=1, worker_concurrency=4, # Beat schedule for periodic tasks beat_schedule={ # Check and publish scheduled posts every minute "check-scheduled-posts": { "task": "app.worker.tasks.check_scheduled_posts", "schedule": 60.0, # Every minute }, # Generate daily content at 6 AM "generate-daily-content": { "task": "app.worker.tasks.generate_daily_content", "schedule": crontab(hour=6, minute=0), }, # Sync interactions every 15 minutes "sync-interactions": { "task": "app.worker.tasks.sync_interactions", "schedule": crontab(minute="*/15"), }, # Send daily summary at 9 PM "send-daily-summary": { "task": "app.worker.tasks.send_daily_summary", "schedule": crontab(hour=21, minute=0), }, # Cleanup old data weekly "cleanup-old-data": { "task": "app.worker.tasks.cleanup_old_data", "schedule": crontab(hour=3, minute=0, day_of_week=0), # Sunday 3 AM }, }, )