pyramid_celery
pyramid_celery copied to clipboard
Environment variable parsing not supported
I want to use an environment variable as my BROKER_URL in a .ini file but it isn't parsed correctly. When I try to do
[celery]
BROKER_URL = ${REDIS_URL}
I get the following error

Actually I have the same issue without using ENV variables, even using the examples
The way you would do this is by using standard template variables in the ini.file and then pass the environment variable over:
broker_url = %(REDIS_URL)s
and then you can use:
celery -A pyramid_celery.celery_app worker --ini development.ini --ini-var=REDIS_URL=$REDIS_URL
I'm going to keep the issue open to consider introducing something like .env or some other sort of environment variable reading on top of that.
I tried that, but couldn't get it to work.
@phrfpeixoto Do you have the config and command you ran so I can see it? and what shell you use (bash, zsh, fish, etc)
I'm putting a PR together to illustrate it.
What fails on me is starting pserve itself: It seems it can only replace variables inside the [main] section of the config.
Please make allowance for environment variables to be parsed...
celery -A pyramid_celery.celery_app worker --ini development.ini --ini-var=REDIS_URL=$REDIS_URL
this is very useful information, but the pyramid application fails to start due to the fact that as @phrfpeixoto pointed out, pserve only replaces variables inside [app:main] and not in [celery]