I have an application that needs to initialize Celery and other things (e.g. database). I would like to have a .ini file that would contain the applications configuration. This should be passed to the application at runtime.
development.init:
[celery]
broker=amqp://localhost/
backend=amqp://localhost/
task.result.expires=3600[database]
# database config
# ...
celeryconfig.py:
from celery import Celery
import ConfigParserconfig = ConfigParser.RawConfigParser()
config.read(...) # Pass this from the command line somehowcelery = Celery('myproject.celery',broker=config.get('celery', 'broker'),backend=config.get('celery', 'backend'),include=['myproject.tasks'])# Optional configuration, see the application user guide.
celery.conf.update(CELERY_TASK_RESULT_EXPIRES=config.getint('celery', 'task.result.expires')
)# Initialize database, etc.if __name__ == '__main__':celery.start()
To start Celery, I call:
celery worker --app=myproject.celeryconfig -l info
Is there anyway to pass in the config file without doing something ugly like setting a environment variable?