The celery documentation helpfully gives an example of a configuration file, but it is less clear on where to put this file, or how to ensure that the worker reads this config file when it boots.
celery.py defines an object of type celery.Celery
called app
, which is what I use to decorate all my tasks. All of the tasks are in /myproj/tasks/
.
My directory structure is a bit like this:
/myproj/celery.py
/celeryconfig.py # my settings
/tasks/ # tasks go here
Is there something I can put into celery.py
which makes it load the celeryconfig.py
file, or do I need to specify it on the worker command-line arguments?
Here's what my config file looks like right now:
## Broker settings.
broker_url = "pyamqp://admin:ypass@mq:5672"
# List of modules to import when the Celery worker starts.
imports = ('stoneid.tasks',)