我正在尝试在新安装的ubuntu 18.04系统上设置graphite-web。我使用了apt数据包管理器,所以我得到了1.0.2版本的graphite-web。我完成了通常的配置,但是我得到了一个"内部服务器错误"当试图在浏览器中打开graphite-web时。石墨网的apache错误日志说:
[Fri May 25 07:02:47.097839 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] mod_wsgi (pid=13350): Exception occurred processing WSGI script '/usr/share/graphite-web/graphite.wsgi'.
[Fri May 25 07:02:47.102111 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] Traceback (most recent call last):
[Fri May 25 07:02:47.102210 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 157, in __call__
[Fri May 25 07:02:47.102389 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] response = self.get_response(request)
[Fri May 25 07:02:47.102535 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 124, in get_response
[Fri May 25 07:02:47.102706 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] response = self._middleware_chain(request)
[Fri May 25 07:02:47.102964 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 43, in inner
[Fri May 25 07:02:47.103063 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] response = response_for_exception(request, exc)
[Fri May 25 07:02:47.103144 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 93, in response_for_exception
[Fri May 25 07:02:47.103263 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
[Fri May 25 07:02:47.103502 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 143, in handle_uncaught_exception
[Fri May 25 07:02:47.103660 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] return callback(request, **param_dict)
[Fri May 25 07:02:47.103737 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/graphite/views.py", line 11, in server_error
[Fri May 25 07:02:47.103889 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] return HttpResponseServerError( template.render(context) )
[Fri May 25 07:02:47.104044 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/template/backends/django.py", line 64, in render
[Fri May 25 07:02:47.104484 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] context = make_context(context, request, autoescape=self.backend.engine.autoescape)
[Fri May 25 07:02:47.104582 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/template/context.py", line 287, in make_context
[Fri May 25 07:02:47.104868 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
[Fri May 25 07:02:47.105070 2018] [wsgi:error] [pid 13350] [remote XXX.XXX.XXX.XXX:XXXX] TypeError: context must be a dict rather than Context.
[Fri May 25 07:02:47.435785 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] mod_wsgi (pid=13387): Exception occurred processing WSGI script '/usr/share/graphite-web/graphite.wsgi'.
[Fri May 25 07:02:47.436040 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] Traceback (most recent call last):
[Fri May 25 07:02:47.436131 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 157, in __call__
[Fri May 25 07:02:47.436272 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] response = self.get_response(request)
[Fri May 25 07:02:47.436386 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 124, in get_response
[Fri May 25 07:02:47.436646 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] response = self._middleware_chain(request)
[Fri May 25 07:02:47.436744 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 43, in inner
[Fri May 25 07:02:47.436876 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] response = response_for_exception(request, exc)
[Fri May 25 07:02:47.437023 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 93, in response_for_exception
[Fri May 25 07:02:47.437173 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
[Fri May 25 07:02:47.437321 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 143, in handle_uncaught_exception
[Fri May 25 07:02:47.437570 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] return callback(request, **param_dict)
[Fri May 25 07:02:47.437755 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/graphite/views.py", line 11, in server_error
[Fri May 25 07:02:47.437960 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] return HttpResponseServerError( template.render(context) )
[Fri May 25 07:02:47.438139 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/template/backends/django.py", line 64, in render
[Fri May 25 07:02:47.438273 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] context = make_context(context, request, autoescape=self.backend.engine.autoescape)
[Fri May 25 07:02:47.438392 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] File "/usr/lib/python2.7/dist-packages/django/template/context.py", line 287, in make_context
[Fri May 25 07:02:47.438609 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
[Fri May 25 07:02:47.438816 2018] [wsgi:error] [pid 13387] [remote XXX.XXX.XXX.XXX:XXXX] TypeError: context must be a dict rather than Context.
起初我认为包含wsgi脚本的目录并非由合适的用户拥有,但结果却并非如此。 (它由Web服务器用户拥有)
目前我正在使用python 2.7,但我能够使用python3复制问题。
我的想法已经不多了。有人可以帮忙吗?
谢谢!
答案 0 :(得分:4)
我设法在usr / lib / python2.7 / dist-packages / graphite / views.py中解决此问题
通过更改
context = Contex({
'stacktrace' : traceback.format_exc()
})
到
context = {
'stacktrace' : traceback.format_exc()
}
问题与以下主题有关: Django 1.11 TypeError context must be a dict rather than Context