Fallback for os env vars
Opened this issue · 1 comments
[watcher:test]
cmd = python test.py
numprocesses = $(circus.env.NUM_TEST_PROCESSES)
Now, if I set os.environ["NUM_TEST_PROCESSES"] = 3
, I'll have 3 "test" processes running
but if that env var is not set, what happens?
can a default be provided - like $(circus.env.NUM_TEST_PROCESSES, 1)
?
there's nothing on the docs for this, but is this even possible with circus?
If I use [env]
or [env:XXX]
sections, those will get precedence no matter what I set in os.environ
Hi, @vdraceil!
Let's break it down.
but if that env var is not set, what happens?
With the config you provided - there will be an exception, because the variables are not interpolated if either [env]
section or copy_env
is specified.
This config should properly handle your environment variables if set.
[watcher:test]
cmd = python test.py
numprocesses = $(circus.env.NUM_TEST_PROCESSES)
copy_env = True
can a default be provided - like
$(circus.env.NUM_TEST_PROCESSES, 1)
?
Unfortunately, no, there is no such feature at the moment. But it is a good suggestion. Although, it might require changing the signature of replace_gnu_args
method, which can be a pain.
Another solution could be falling back to default values, not sure why it is not done yet.
there's nothing on the docs for this
I agree, the docs could use some polishing and more notes about environment variables. I will try to do something about that.