pyramid_celery icon indicating copy to clipboard operation
pyramid_celery copied to clipboard

Environment variable parsing not supported

Open humzaiqbal opened this issue 9 years ago • 6 comments

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

humzaiqbal avatar Jul 17 '16 19:07 humzaiqbal

Actually I have the same issue without using ENV variables, even using the examples

aristobulo-eezee avatar Dec 09 '16 08:12 aristobulo-eezee

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.

sontek avatar Feb 24 '21 03:02 sontek

I tried that, but couldn't get it to work.

phrfpeixoto avatar Feb 28 '21 21:02 phrfpeixoto

@phrfpeixoto Do you have the config and command you ran so I can see it? and what shell you use (bash, zsh, fish, etc)

sontek avatar Feb 28 '21 23:02 sontek

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.

phrfpeixoto avatar Feb 28 '21 23:02 phrfpeixoto

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]

renierdbruyn avatar Mar 17 '22 12:03 renierdbruyn