-
Notifications
You must be signed in to change notification settings - Fork 34
Description
I needed to add a periodic task to the deployment of Invenio I'm working on, but found that the documentation is not quite correct (it may possibly just be outdated).
The documentation suggests creating a dict
called CELERYBEAT_SCHEDULE
in config.py
like so:
# config.py
CELERYBEAT_SCHEDULE = {
'indexer': {
'task': 'invenio_indexer.tasks.process_bulk_queue',
'schedule': timedelta(minutes=5),
},
}
For one thing, it appears the correct name of the variable is CELERY_BEAT_SCHEDULE
(note the extra underscore!), but it may also be worth mentioning that you need to import this variable from invenio_app_rdm.config
-- it won't work if you create a new variable by that name in your config.py
.
You also probably want to add a new entry to the dict
rather than replacing it. Here's what I did:
# Periodic tasks
# --------------
CELERY_BEAT_SCHEDULE["update_imperial_users"] = {
"task": "ic_data_repo.tasks.update_imperial_users",
"schedule": timedelta(weeks=1),
}
I also missed the step where you have to define the invenio_celery.tasks
entrypoint to your package. I've noticed it is mentioned in passing, but maybe this information should be a bit more prominent?