我正在尝试在 Gunicorn 下运行现有的 uWSGI 连接的 Django 应用程序(实际上是一组应用程序)。 uWSGI 配置是:
[uwsgi]
plugins = python27
home = /var/www/uwsgi/webapp/app/venv
chdir = /var/www/uwsgi/webapp
chdir2 = /var/www/uwsgi/webapp/app
module = uwsgi_app
processes = 150
master = true
socket = 127.0.0.1:3031
socket-timeout = 300
env = DJANGO_SETTINGS_MODULE=settings
当我尝试使用此命令行从 /var/www/uwsgi/webapp
运行 gunicorn
时:
gunicorn_django --bind 127.0.0.1:9031 --access-logfile /tmp/gunicorn.log --error-logfile /tmp/gunicorn.err --workers=40
它开始了,但我在它的错误日志中得到以下信息:
2013-09-19 08:17:16 [2981] [ERROR] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 131, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 82, in get_response
urlconf = settings.ROOT_URLCONF
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 277, in __getattr__
return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'
我的理解是 settings.py
中没有 ROOT_URLCONF
,因为中间件应该在具有单独 urlconf 的多个应用程序之间路由。但看起来 gunicorn
对此并不满意。我该怎么办?
最佳答案
好的,我明白了,这个应用程序有两个不同的设置副本,一个在 settings.py
(未使用)中,另一个在 ./app/settings/*.py
(真实)。搜索 ROOT_URLCONF
的来源揭示了真实设置的隐藏位置。
关于python - 将基于 uWSGI 的 Django 网络应用程序转换为基于 gunicorn 的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18896682/