Added support for periodic Celery tasks.
You have to run "manage.py celery beat" for this to work too. Run "manage.py celery beat -- --help" to get CLI option help.
This commit is contained in:
@@ -465,6 +465,13 @@ class PillarServer(Eve):
|
|||||||
result_expires=3600,
|
result_expires=3600,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# This configures the Celery task scheduler in such a way that we don't
|
||||||
|
# have to import the pillar.celery.XXX modules. Remember to run
|
||||||
|
# 'manage.py celery beat' too, otherwise those will never run.
|
||||||
|
beat_schedule = self.config.get('CELERY_BEAT_SCHEDULE')
|
||||||
|
if beat_schedule:
|
||||||
|
self.celery.conf.beat_schedule = beat_schedule
|
||||||
|
|
||||||
self.log.info('Pinging Celery workers')
|
self.log.info('Pinging Celery workers')
|
||||||
self.log.info('Response: %s', self.celery.control.ping())
|
self.log.info('Response: %s', self.celery.control.ping())
|
||||||
|
|
||||||
|
@@ -58,3 +58,12 @@ def purge():
|
|||||||
|
|
||||||
log.warning('Purging all pending Celery tasks.')
|
log.warning('Purging all pending Celery tasks.')
|
||||||
current_app.celery.control.purge()
|
current_app.celery.control.purge()
|
||||||
|
|
||||||
|
|
||||||
|
@manager_celery.option('args', nargs='*')
|
||||||
|
def beat(args):
|
||||||
|
"""Runs the Celery beat."""
|
||||||
|
|
||||||
|
from celery.bin.beat import beat
|
||||||
|
|
||||||
|
return beat(app=current_app.celery).run_from_argv('je moeder', args, command='beat')
|
||||||
|
@@ -178,6 +178,16 @@ TLS_CERT_FILE = requests.certs.where()
|
|||||||
CELERY_BACKEND = 'redis://redis/1'
|
CELERY_BACKEND = 'redis://redis/1'
|
||||||
CELERY_BROKER = 'amqp://guest:guest@rabbit//'
|
CELERY_BROKER = 'amqp://guest:guest@rabbit//'
|
||||||
|
|
||||||
|
# This configures the Celery task scheduler in such a way that we don't
|
||||||
|
# have to import the pillar.celery.XXX modules. Remember to run
|
||||||
|
# 'manage.py celery beat' too, otherwise those will never run.
|
||||||
|
CELERY_BEAT_SCHEDULE = {
|
||||||
|
'regenerate-expired-links': {
|
||||||
|
'task': 'pillar.celery.file_link_tasks.regenerate_all_expired_links',
|
||||||
|
'schedule': 600.0,
|
||||||
|
'args': ('gcs', 100)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# Mapping from user role to capabilities obtained by users with that role.
|
# Mapping from user role to capabilities obtained by users with that role.
|
||||||
USER_CAPABILITIES = defaultdict(**{
|
USER_CAPABILITIES = defaultdict(**{
|
||||||
|
Reference in New Issue
Block a user