Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supervisord using environment variables in command

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?

like image 731
jdevops Avatar asked Feb 09 '15 13:02

jdevops


People also ask

How do I use environment variables in Supervisord?

Environment Variables¶. Environment variables that are present in the environment at the time that supervisord is started can be used in the configuration file using the Python string expression syntax %(ENV_X)s: In the example above, the expression %(ENV_LOGLEVEL)s would be expanded to the value of the environment variable LOGLEVEL.

How do I set system-wide environment variables?

Note: Any user environment variable can be set or modified in a regular Command Prompt window, but changing system-wide environment variables requires an elevated Command Prompt. There are two distinct ways to set environment variables. The first uses the set command.

How do I change system variables in CMD?

First, you need to launch Command Prompt, or CMD, as an administrator. Click Start, type “cmd” into the search box, and then click “Run as Administrator.” Note: Any user environment variable can be set or modified in a regular Command Prompt window, but changing system-wide environment variables requires an elevated Command Prompt.

How do I set an environment variable in Linux?

There are two distinct ways to set environment variables. The first uses the set command. Set defines an environment variable exclusively within the process in which it has been defined — in other words, the variable only works in the window you have open or the script that contains it.


1 Answers

Looks like you are missing the leading s in formatting environment variable name. Here is sample config file.

You should use

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

For readability

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
like image 196
Pandikunta Anand Reddy Avatar answered Oct 11 '22 17:10

Pandikunta Anand Reddy