Functions
Via Inheritance from supervisord:
As long as you use version 3.0a10 or higher, you can set the environment variables in the [supervisord] environment , and they will be in the environment of all processes under the supervision of a supervisor.
[supervisord] ... environment=FAVORITE_VENTURE="RUSTY",FAVORITE_COLOR="RED"
Working with supervisord variables inherited from the shell
Supervisord also has a %(ENV_VARNAME)s extension format for interpreting environment variables that allow variable names to be moved across processes. But the configuration section of the configuration does not add to the environment variables accessible by the %(ENV_)s mechanism, so it would be necessary to call superisord with variables that are already set by your shell.
As an example, if you use initialization scripts to start a supervisor and are on a debian-based system (e.g. Ubuntu), you can start with the following in / etc / default / supervisor:
export SUPERVISOR_INCLUDES="main.conf test.conf" export MAIN_RETRY_COUNT=2 export TEST_RETY_COUNT=1 MONGO_BASE="MONGO_URL=mongodb://path.to.mongo" MAIN_MONGO_URL="${MONGO_BASE}:27017" TEST_MONGO_URL="${MONGO_BASE}:27018" export MAIN_ENV="${MAIN_MONGO_URL},OTHER_THING=\"Another thing with escaped quoting\"" export TEST_ENV=..
Then use them in configurations:
; supvervisord.conf [includes] files= %(here)s/subdir/other.conf %(ENV_SUPERVISOR_INCLUDES)s ; main.conf [group:main] ... [program:mainbackend] startretries=%(ENV_MAIN_RETRY_COUNT)s environment=%(ENV_MAIN_ENV)s
If users can use sudo and directly call supervisord, this method does not work very well, since sudo both restricts the user environment and does not run traditional shell init scripts. But you can source /etc/default/supervisor in the root .bashrc and use sudo bash -c "supervisord .." or specify it before calling supervisord.
source share