uwsgi.ini:
[uwsgi]
wsgi-file = /home/ubuntu/app/wsgi.py
chdir = /home/ubuntu/app/
uid = www-data
gid = www-data
chown-socket = www-data
processes = 4
async = 100
gevent = 100
socket = /run/uwsgi.sock
logto = /var/log/uwsgi.log
logdate = true
post-buffering = 4096
master = true
die-on-term = true
logfile-chown = true
no-site = true
uwsgi.conf:
description "uwsgi tiny instance"
start on runlevel [2345]
stop on runlevel [06]
script
exec uwsgi /home/ubuntu/app/wsgi.ini
end script
pre-stop script
rm /run/uwsgi.pid
end script
运行sudo service uwsgi start
时的错误日志:
Mon Dec 22 06:58:20 2014 - *** Starting uWSGI 2.0.6 (64bit) on [Mon Dec 22 06:58:20 2014] ***
Mon Dec 22 06:58:20 2014 - compiled with version: 4.6.3 on 11 August 2014 23:31:50
Mon Dec 22 06:58:20 2014 - os: Linux-3.2.0-69-virtual #103-Ubuntu SMP Tue Sep 2 05:21:29 UTC 2014
Mon Dec 22 06:58:20 2014 - nodename: ip-10-166-222-26
Mon Dec 22 06:58:20 2014 - machine: x86_64
Mon Dec 22 06:58:20 2014 - clock source: unix
Mon Dec 22 06:58:20 2014 - detected number of CPU cores: 1
Mon Dec 22 06:58:20 2014 - current working directory: /
Mon Dec 22 06:58:20 2014 - detected binary path: /usr/local/bin/uwsgi
Mon Dec 22 06:58:20 2014 - !!! no internal routing support, rebuild with pcre support !!!
Mon Dec 22 06:58:20 2014 - your processes number limit is 4592
Mon Dec 22 06:58:20 2014 - your memory page size is 4096 bytes
Mon Dec 22 06:58:20 2014 - detected max file descriptor number: 1024
Mon Dec 22 06:58:20 2014 - - async cores set to 100 - fd table size: 1024
Mon Dec 22 06:58:20 2014 - lock engine: pthread robust mutexes
Mon Dec 22 06:58:20 2014 - thunder lock: disabled (you can enable it with --thunder-lock)
Mon Dec 22 06:58:20 2014 - uwsgi socket 0 bound to UNIX address /run/uwsgi.sock fd 3
Mon Dec 22 06:58:20 2014 - setgid() to 33
Mon Dec 22 06:58:20 2014 - setuid() to 33
Mon Dec 22 06:58:20 2014 - Python version: 2.7.3 (default, Feb 27 2014, 20:09:21) [GCC 4.6.3]
Mon Dec 22 06:58:20 2014 - Python main interpreter initialized at 0x23e5ec0
Mon Dec 22 06:58:20 2014 - python threads support enabled
Mon Dec 22 06:58:20 2014 - your server socket listen backlog is limited to 100 connections
Mon Dec 22 06:58:20 2014 - your mercy for graceful operations on workers is 60 seconds
Mon Dec 22 06:58:20 2014 - mapped 9560320 bytes (9336 KB) for 400 cores
Mon Dec 22 06:58:20 2014 - *** Operational MODE: preforking+async ***
Traceback (most recent call last):
File "/home/ubuntu/app/wsgi.py", line 1, in <module>
from gevent import monkey
ImportError: No module named gevent
为什么会这样?当我在shell中运行python并导入gevent时,一切正常。
答案 0 :(得分:0)
检查已安装uWSGI插件的命令:uwsgi --plugin-list
如果安装了插件,但出现错误-> ImportError: No module named gevent
,
然后安装uwsgi:pip install uwsgi