7

I'm attempting to run a series of Python apps from supervisor. It works fine on Mac OSX, but when I attempt to run the same app on Ubuntu, supervisor doesn't seem to be activating the virtualenv so my scripts are throwing errors.

Here is my structure:

/home/user/Sites/my-site
- app.py
- venv
- supervisor.conf

My supervisor.conf file looks like this:

[program:python-app]
autorestart = false
autostart = false
startsecs = 0
command = python app.py
startretries = 1
environment=PYTHONPATH="%(here)s"

[unix_http_server]
file = /tmp/supervisor.sock

[supervisord]
logfile = logs/supervisord.log
pidfile = logs/supervisord.pid
environment=PYTHONPATH="%(here)s"

[supervisorctl]
serverurl = unix:///tmp/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[unix_http_server]
username = supervisor_admin
password = 

[inet_http_server]
username = supervisor_admin
password = 
port = *:9001

How can I get supervisor to run the python app inside of the virtual enviroment?

Hanpan
  • 193

1 Answers1

17

The command you provide should use the python binary inside the virtual environment:

command = /home/user/Sites/my-site/venv/bin/python /home/user/Sites/my-site/app.py
mgorven
  • 31,399