How to configure Celery¶
Note
This article assumes that you are already familiar with the basics of usingCelery with Django. If not, please see .
Celery needs to be set up by our infrastructure team. See Celery on DivioCloud for more information.
Your project will be set up with two new environment variables:
- BROKER_URL
- RABBITMQ_ERLANG_COOKIE
Test and Live servers will have different values for both.
filecontains a number of settings that can be configured as environment variables.
You will need to add some new services to your docker-compose.yml file.
RabbitMB¶
Set up the RabbitMQ messaging service:
Celery worker¶
- command: aldryn-celery worker
You will also need to add all of the other options already applied to theweb
service in the same file, except the ports
option.
To the links
option, add:
- - "rabbitmq:rabbitmq"
In other words, the celery
service should now include something like:
These are required because the needs access to the same Pythoncomponents and environment as the web applications.
Celery beat¶
The needs to be set up in much the same way.
- celerybeat:
- command: aldryn-celery beat
Copy over the other options from celeryworker
.
Celery cam¶
The cam
service captures events for monitoring purposes.
- celerycam:
- command: aldryn-celery cam
followed once again by the other options from celeryworker
.
The web service¶
Finally, to the links
option in , add:
In .env-local
add:
- RABBITMQ_ERLANG_COOKIE=<secret cookie value>
- BROKER_URL="amqp://guest:[[email protected]](http://docs.divio.com/cdn-cgi/l/email-protection):5672/"
docker-compose up
or divio project up
will now also start Celery.
Environment variable changes¶
If you change environment variables locally, the containers will need to bestopped and restarted in order to pick up the changes.
Configuration changes¶
When making project configuration changes, you will need to rebuild allthe containers:
Code changes¶
Unlike the web
container, Celery’s containers will not be reloaded onPython code changes, so you will need to run manually when required (the other containers shouldn’t generallyneed to be restarted).