25

I can't seem to figure out how to append to the default path in a supervisord program config.

I can reset the path:

environment=PATH="/home/site/environments/master/bin"

But when I try:

environment=PATH="/home/site/environments/master/bin:$PATH"

I see that supervisord doesn't evaluate $PATH.

Google wasn't a big help on this for some reason, I cannot believe I'm the first person to need this.

Supervisord must have support for this, any idea what it is?

Prody
  • 613
  • 3
  • 7
  • 16
  • 1
    @ascobol nope, I've hardcoded the path I need, for now – Prody Jan 17 '12 at 10:36
  • 2
    `supervisord` don't run shell to preprocess variables in the config file, so you can't use shell expressions to expand variables. Although there is a patch that allows to do `%($PATH)` and it was discussed in mailing lists back in 2011 but AFAIK it is still not included to the mainline source tree. As a workaround you can create a script that will setup environment and execute a command supplied in arguments. Then you just run the script from the `supervisord` like `command /usr/local/bin/setup_env_master.sh program_name arguments` – Dmitry Dec 02 '12 at 17:49
  • 1
    There is a significant drawback to the shell wrapper solution - when supervisor will try to stop the process using INT or KILL, the signal will be received by the bash script and not the actual wrapped program. This may lead (and leads in my case) to dangling processes. – stoiczek Apr 15 '14 at 19:34
  • @stoiczek easy problem to solve. Use exec at the end of the bash script, do not just run the command regularly. So `exec server --args`. You see it in upstart jobs invariably. – CameronNemo Jul 01 '14 at 17:27

2 Answers2

22

This feature has been added to Supervisor back in 2014

environment=PATH="/home/site/environments/master/bin:%(ENV_PATH)s"

see https://github.com/Supervisor/supervisor/blob/95ca0bb6aec582885453899872c60b4174ccbd58/supervisor/skel/sample.conf#L7

See also https://stackoverflow.com/questions/12900402/supervisor-and-environment-variables

Thomas Grainger
  • 335
  • 2
  • 7
1

I reviewed the documentation and agree with Dmitry.

The current answer is: supervisor doesn't do this directory, but creating a wrapper script will help.

Theuni
  • 958
  • 5
  • 15