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.

50 lines
1.5 KiB
Python

from __future__ import absolute_import, unicode_literals
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', 'ccvpn.settings')
app = Celery('ccvpn')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
app.conf.beat_schedule = {
'payments__check_subscriptions': {
'task': 'payments.tasks.check_subscriptions',
'schedule': timedelta(hours=24),
},
'payments__cancel_old_payments': {
'task': 'payments.tasks.cancel_old_payments',
'schedule': timedelta(hours=24),
},
'lambdainst__resync': {
'task': 'lambdainst.tasks.push_all_users',
'schedule': timedelta(days=7),
},
'lambdainst__notify_account_expiration': {
'task': 'lambdainst.tasks.notify_account_expiration',
'schedule': timedelta(hours=6),
},
'lambdainst__notify_vpn_auth_fails': {
'task': 'lambdainst.tasks.notify_vpn_auth_fails',
'schedule': timedelta(days=30),
},
}
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))