我正在尝试从主管运行一系列 Python 应用程序。它在 Mac OSX 上运行良好,但当我尝试在 Ubuntu 上运行相同的应用程序时,主管似乎没有激活虚拟环境,所以我的脚本抛出了错误。
这是我的结构:
/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 应用程序?
答案1
您提供的命令应该使用python
虚拟环境内的二进制文件:
command = /home/user/Sites/my-site/venv/bin/python /home/user/Sites/my-site/app.py