【问题标题】:Debugging Django/Gunicorn behind Nginx在 Nginx 后面调试 Django/Gunicorn
【发布时间】:2012-08-30 19:56:57
【问题描述】:

全新安装 Nginx、Gunicorn、Supervisor、New Relic、Django、Postgres 等。点击 URL 会导致“内部服务器错误”。

在 Nginx 配置中打开调试提供了很多详细信息,但没有任何内容指出导致 500 错误的原因(只是它正在发生。)

接下来,我通过 supervisorctl 关闭 Gunicorn,并通过 python manage.py runserver 启动应用程序,点击 URL,一切正常。

后退一步,关闭 runserver 并使用 bin/gunicorn_django 手动启动 Gunicorn,这是我能找到的最接近可用跟踪日志的:

2012-09-05 21:39:25 [5927] [ERROR] Error handling request
Traceback (most recent call last):
  File "/somewhere/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 102, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/somewhere/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/somewhere/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 82, in get_response
    urlconf = settings.ROOT_URLCONF
  File "/somewhere/local/lib/python2.7/site-packages/django/utils/functional.py", line 185, in inner
    return func(self._wrapped, *args)
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'

我不是要回答这里发生的事情,因为我知道这还不够详细,无法弄清楚。 ROOT_URLCONF 问题是通用的,可能是由很多事情引起的。我的问题是我可以使用哪些后续步骤来继续追踪正在发生的事情?

谢谢

【问题讨论】:

  • 问题恰好是gunicorn实际上无法找到设置文件。在我的主管配置中指定设置所在的目录后,它开始工作。很高兴我弄清楚了,但仍然对为什么有必要感到困惑。相同的应用程序可以在其他 2 台服务器上正常运行,无需此规范。

标签: django debugging nginx gunicorn


【解决方案1】:

提到Settings 而不是settings(注意大写)是可疑的。我个人在使用 Aptana Studio 时注意到,键入 from django.conf import 后出现的自动完成选项之一是 Settings,但这显然不是您真正想要的。也许发生了类似的事情并且您接受了错误的自动完成选择?我会在你的项目中搜索Settings(当然要区分大小写),并酌情将其更改为小写。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-28
    • 2012-10-24
    • 2013-03-25
    • 2013-03-01
    • 2021-03-19
    • 1970-01-01
    • 2017-12-08
    • 2016-01-04
    相关资源
    最近更新 更多