如果我在Django项目的wsgi.py
中使用eventlet,我可以使用uWSGI吗?
在我的项目中wsgi.py
:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AProject.settings")
from socketio import Middleware
from xxx.website_chat.views import sio
django_app = get_wsgi_application()
application = Middleware(sio, django_app)
import eventlet
import eventlet.wsgi
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
我使用eventlet.wsgi.server()
做我的应用程序,无论我分发项目时,还是需要uWSGI作为网络服务器吗?
修改-1
我的意思是,如果我使用下面的代码,我仍然需要uWSGI作为网络服务器:
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
修改-2
我在项目eventlet.wsgi.server
中使用wsgi.py
:
import eventlet.wsgi
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
现在我想发布我的项目。
当我使用uwsgi --ini uwsgi.ini
时:
会出现以下错误:
mapped 208320 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
django.setup()
Traceback (most recent call last):
File "myProject/wsgi.py", line 30, in <module>
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
File "/Users/lll/Desktop/myProject/Project/myProject/venv/lib/python3.5/site-packages/eventlet/convenience.py", line 78, in listen
sock.bind(addr)
OSError: [Errno 48] Address already in use
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 11413)
spawned uWSGI worker 1 (pid: 11418, cores: 4)
spawned uWSGI http 1 (pid: 11419)
我使用lsof -i:8000
发现uwsgi
正在使用8000
端口。
$ lsof -i:8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
uwsgi 11413 ldl 4u IPv4 0x9bf2de3fe3ee0367 0t0 TCP *:irdmi (LISTEN)
uwsgi 11419 ldl 4u IPv4 0x9bf2de3fe3ee0367 0t0 TCP *:irdmi (LISTEN)
所以eventlet.wsgi无法收听地址:eventlet.listen(('', 8000))
当我分发我的项目时,我不需要uWSGI吗?直接使用eventlet.wsgi.server?