Supervisor and Environment Variables

Tampa picture Tampa · Oct 15, 2012 · Viewed 84.2k times · Source

I really don't know how to get supervisor to work with environment variables.

Below is a configuration snippet.

[program:htNotificationService]
priority=2
#autostart=true
#autorestart=true
directory=/home/ubuntu/workspace/htFrontEnd/heythat/htsite
command = /usr/bin/python htNotificationService.py -service
stdout_logfile=/var/log/heythat/htNotificationService.log
redirect_stderr=true
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat
stopsignal=QUIT

I have tried the following:

environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat
environment=PYTHONPATH=$PYTHONPATH:/home/ubuntu/workspace/htFrontEnd/heythat
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat,PYTHONPATH=$PYTHONPATH:/home/ubuntu/workspace/htFrontEnd/heythat

When I start supervisor I get

htNotificationService: ERROR (abnormal termination)

I can start from the shell by setting the python path, but not from supervisor. In the logs I get an error that says that an import can't be found. Well, that would be solved if supervisor would work. I even have the path in /etc/environments?

Why will supervisor not work?

Answer

edibleEnergy picture edibleEnergy · Oct 26, 2013

Referencing existing env vars is done with %(ENV_VARNAME)s

( see https://github.com/Supervisor/supervisor/blob/master/supervisor/skel/sample.conf )

Setting multiple environment variables is done by separating them with commas

( see http://supervisord.org/subprocess.html#subprocess-environment )

Try:

environment=PYTHONPATH=/opt/mypypath:%(ENV_PYTHONPATH)s,PATH=/opt/mypath:%(ENV_PATH)s