Subprocess Environment

Subprocesses will inherit the environment of the shell used to startthe supervisord program. Several environment variableswill be set by supervisord itself in the child’senvironment also, including SUPERVISOR_ENABLED (a flagindicating the process is under supervisor control),SUPERVISOR_PROCESS_NAME (the config-file-specified processname for this process) and SUPERVISOR_GROUP_NAME (theconfig-file-specified process group name for the child process).

These environment variables may be overridden within the[supervisord] section config option named environment (appliesto all subprocesses) or within the per- [program:x] sectionenvironment config option (applies only to the subprocessspecified within the [program:x] section). These “environment”settings are additive. In other words, each subprocess’ environmentwill consist of:

The environment variables set within the shell used to startsupervisord…

… added-to/overridden-by …

… the environment variables set within the “environment” global
config option …

… added-to/overridden-by …

… supervisor-specific environment variables
(SUPERVISOR_ENABLED,SUPERVISOR_PROCESS_NAME,SUPERVISOR_GROUP_NAME) ..

… added-to/overridden-by …

… the environment variables set within the per-process
“environment” config option.

No shell is executed by supervisord when it runs asubprocess, so environment variables such as USER,PATH, HOME, SHELL, LOGNAME,etc. are not changed from their defaults or otherwise reassigned.This is particularly important to note when you are running a programfrom a supervisord run as root with a user= stanza inthe configuration. Unlike cron, supervisorddoes not attempt to divine and override “fundamental” environmentvariables like USER, PATH, HOME, andLOGNAME when it performs a setuid to the user defined withinthe user= program config option. If you need to set environmentvariables for a particular program that might otherwise be set by ashell invocation for a particular user, you must do it explicitlywithin the environment= program config option. Anexample of setting these environment variables is as below.

  1. [program:apache2]
  2. command=/home/chrism/bin/httpd -c "ErrorLog /dev/stdout" -DFOREGROUND
  3. user=chrism
  4. environment=HOME="/home/chrism",USER="chrism"