Ubuntu

Ubuntu - Supervisord 和 virtualenv

  • February 28, 2013

我正在嘗試從主管執行一系列 Python 應用程序。它在 Mac OSX 上執行良好,但是當我嘗試在 Ubuntu 上執行相同的應用程序時,主管似乎沒有啟動 virtualenv,所以我的腳本拋出錯誤。

這是我的結構:

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

我的 supervisor.conf 文件如下所示:

[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

如何讓主管在虛擬環境中執行 python 應用程序?

您提供的命令應該使用python虛擬環境中的二進製文件:

command = /home/user/Sites/my-site/venv/bin/python /home/user/Sites/my-site/app.py

引用自:https://serverfault.com/questions/483438