You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
792 B
Python
24 lines
792 B
Python
|
|
import os
|
|
from celery import Celery
|
|
from celery.schedules import crontab
|
|
from datetime import timedelta
|
|
# Set the default Django settings module for the 'celery' program.
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'osinaweb.settings')
|
|
|
|
# Create a Celery instance.
|
|
celery_app = Celery('osinaweb', broker_url='redis://127.0.0.1:6379/0')
|
|
|
|
# Load task modules from all registered Django app configs.
|
|
celery_app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
|
|
# Autodiscover tasks from all registered apps
|
|
celery_app.autodiscover_tasks()
|
|
|
|
celery_app.conf.beat_schedule = {
|
|
'set-offline-every-minute': {
|
|
'task': 'osinacore.tasks.set_offline', # Assuming your task is in tasks.py in your_app
|
|
'schedule': crontab(minute='*/3'), # Run every minute
|
|
},
|
|
}
|