我无法使用upstart / supervisord运行uwsgi,我使用pyenv
使用virtualenv myenv
设置python,myenv
使用python3.4.3
并且系统的python指向{ {1}}。我把pyenv global改为3.4.3。
现在python2.7.6
,my_user
=> which python
和/home/my_user/.pyenv/shims/python
=> python --version
。
当我使用sudo时,我得到Python 3.4.3
=> sudo which python
和/usr/bin/python
=> sudo python --version
。
Python 2.7.6
已
/etc/init/uwsgi_servers.conf
和description "uWSGI instance to serve authservice in production"
start on runlevel [2345]
stop on runlevel [!2345]
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites/ --uid my_user --gid my_user
已
/etc/uwsgi/sites/uwsgi.ini
当我运行[uwsgi]
# variables
projectname = accounts
base = /home/my_user/django/accounts/
for-readline = /home/my_user/conf/django/accounts/env_var
env = %(_)
endfor =
# config
chdir = /home/my_user/django/accounts/
master = True
processes = 5
protocol = uwsgi
env = in_accounts.settings.production
module = in_accounts.wsgi
socket = /tmp/uwsgi_%(projectname).sock
chmod-socket = 666
home = /home/my_user/.virtualenvs/accounts_production
logto = %(base)/logs/uwsgi.log
daemonize = /var/log/uwsgi/%(projectname).log
vacuum = True
pidfile = /tmp/%(projectname).pid
die-on-term = true
时,我从日志中收到错误
sudo service uwsgi_servers start
从日志中我可以看到,使用upstart启动uwsgi会尝试使用*** Starting uWSGI 2.0.11.2 (64bit) on [Tue Oct 13 09:32:18 2015] ***
compiled with version: 4.8.4 on 12 October 2015 11:59:31
os: Linux-3.16.0-43-generic #58~14.04.1-Ubuntu SMP Mon Jun 22 10:21:20 UTC 2015
nodename: st-auths-web1
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/sites
writing pidfile to /tmp/accounts.pid
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/my_user/django/accounts/current
your processes number limit is 13731
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi_accounts.sock fd 3
Python version: 2.7.6 (default, Jun 22 2015, 18:01:27) [GCC 4.8.2]
Set PythonHome to /home/my_user/.virtualenvs/accounts_production
ImportError: No module named site
VACUUM: pidfile removed.
VACUUM: unix socket /tmp/uwsgi_accounts.sock removed.
,因为我使用python2.7.6
来运行upstart服务,但它应该使用sudo
,这可能是原因为什么服务器没有运行。虽然我使用python3.4.3
和uid
但我收到了上述错误。我也尝试了gid
和setuid
,但没有运气。
注意:我可以成功运行uwsgi服务器,setgid
为upstart
。我尝试使用uwsgi --emperor /etc/uwsgi/sites/
,但没有用,得到同样的错误。
答案 0 :(得分:1)
要完成这项工作,你必须告诉wsgi哪个virtualenv使用-H选项。如果您的virtualenv位于您的主文件夹中,则upstart将无法访问它。所以把它移到一个可读的地方然后试试
uwsgi -H /usr/local/virtualenv
或类似的东西,在你的upstart文件中有正确的virtualenv路径。