Discussion:
[Supervisor-users] Supervisord using enviornment variables in command
Josh Joy
2015-02-09 20:20:43 UTC
Permalink
Hi,

I'm trying to use environment variables in my command, though unable to
run.

My supervisor configuration file

environment=USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)
command=/usr/local/opt/python/bin/flower --basic_auth=%(ENV_USER}:%(ENV_PASS)

When I start supervisord, I receive the following error

Restarting supervisor: Error: Format string
'USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)' for
'environment' is badly formatted

Any ideas?

Thanks,
Josh
Aryeh Leib Taurog
2015-02-09 20:28:54 UTC
Permalink
You need an 's' after the closing parenthesis:

environment=USER=%(ENV_FLOWER_USER_NAME)s,PASS=%(ENV_FLOWER_PASSWORD)s
command=/usr/local/opt/python/bin/flower --basic_auth=%(ENV_USER)s:%(ENV_PASS)s

See the python string formatting documentation for more on this:
<https://docs.python.org/release/2.7/library/stdtypes.html#string-formatting-operations>
Post by Josh Joy
Hi,
I'm trying to use environment variables in my command, though unable to
run.
My supervisor configuration file
environment=USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)
command=/usr/local/opt/python/bin/flower --basic_auth=%(ENV_USER}:%(ENV_PASS)
When I start supervisord, I receive the following error
Restarting supervisor: Error: Format string
'USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)' for
'environment' is badly formatted
Any ideas?
Thanks,
Josh
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Josh Joy
2015-02-09 20:36:10 UTC
Permalink
Post by Aryeh Leib Taurog
environment=USER=%(ENV_FLOWER_USER_NAME)s,PASS=%(ENV_FLOWER_PASSWORD)s
command=/usr/local/opt/python/bin/flower
Post by Aryeh Leib Taurog
--basic_auth=%(ENV_USER)s:%(ENV_PASS)s
Post by Aryeh Leib Taurog
<
https://docs.python.org/release/2.7/library/stdtypes.html#string-formatting-operations
I now receive for the following

environment=USER=%(ENV_FLOWER_USER_NAME)s,PASS=%(ENV_FLOWER_PASSWORD)s
command=/usr/local/opt/python/bin/flower
--basic_auth=%(ENV_USER)s:%(ENV_PASS)s

Restarting supervisor: Error: Format string
'/usr/local/opt/python/bin/flower --basic_auth=%(ENV_USER)s:%(ENV_PASS)s'
for 'command' contains names which cannot be expanded
Post by Aryeh Leib Taurog
environment=USER=%(ENV_FLOWER_USER_NAME)s,PASS=%(ENV_FLOWER_PASSWORD)s
command=/usr/local/opt/python/bin/flower
--basic_auth=%(ENV_USER)s:%(ENV_PASS)s
<
https://docs.python.org/release/2.7/library/stdtypes.html#string-formatting-operations
Post by Aryeh Leib Taurog
Hi,
I'm trying to use environment variables in my command, though unable to
run.
My supervisor configuration file
environment=USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)
command=/usr/local/opt/python/bin/flower
--basic_auth=%(ENV_USER}:%(ENV_PASS)
Post by Aryeh Leib Taurog
When I start supervisord, I receive the following error
Restarting supervisor: Error: Format string
'USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)' for
'environment' is badly formatted
Any ideas?
Thanks,
Josh
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Aryeh Leib Taurog
2015-02-09 20:48:01 UTC
Permalink
This post might be inappropriate. Click to display it.
Josh Joy
2015-02-09 20:49:49 UTC
Permalink
Yes, thanks!
Post by Aryeh Leib Taurog
It looks like you're trying to set environment variables in the first
line and then access them via the new name in the second line. I
don't think it works that way. The `environment` line sets the
environment for the child process, not for supervisord, but the `ENV_`
prefix gives you access only to supervisord's environment. Possibly
command=/usr/local/opt/python/bin/flower
--basic_auth=%(ENV_FLOWER_USER_NAME)s:%(ENV_FLOWER_PASSWORD)s
Alternatively you could execute the python process via a shell script.
This is a common approach to setting up the environment. You must
however make sure that you exec the correct process at the end of the
#!/bin/bash
# startflower.sh
USER=$ENV_FLOWER_USER_NAME
PASS=$ENV_FLOWER_PASSWORD
exec /usr/local/opt/python/bin/flower --basic_auth=$USER:$PASS
# flower.conf
command=/path/to/startflower.sh
Post by Aryeh Leib Taurog
environment=USER=%(ENV_FLOWER_USER_NAME)s,PASS=%(ENV_FLOWER_PASSWORD)s
command=/usr/local/opt/python/bin/flower
--basic_auth=%(ENV_USER)s:%(ENV_PASS)s
Post by Aryeh Leib Taurog
<
https://docs.python.org/release/2.7/library/stdtypes.html#string-formatting-operations
Post by Aryeh Leib Taurog
Post by Josh Joy
Hi,
I'm trying to use environment variables in my command, though unable to
run.
My supervisor configuration file
environment=USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)
command=/usr/local/opt/python/bin/flower
--basic_auth=%(ENV_USER}:%(ENV_PASS)
Post by Aryeh Leib Taurog
Post by Josh Joy
When I start supervisord, I receive the following error
Restarting supervisor: Error: Format string
'USER=%(ENV_FLOWER_USER_NAME),PASS=%(ENV_FLOWER_PASSWORD)' for
'environment' is badly formatted
Any ideas?
Thanks,
Josh
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Loading...