石墨网和 ubuntu 18.04

Posted

技术标签:

【中文标题】石墨网和 ubuntu 18.04【英文标题】:graphite-web and ubuntu 18.04 【发布时间】:2018-05-25 07:22:34 【问题描述】:

我正在尝试在新安装的 ubuntu 18.04 系统上设置石墨网络。我使用了 apt 数据包管理器,所以我得到了 1.0.2 版本的石墨网络。我照常完成了配置,但是尝试在浏览器中打开石墨网络时出现“内部服务器错误”。石墨网络的 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-servers 用户所有)

目前我使用的是 python 2.7,但我能够使用 python3 复制问题。

我的想法不多了。有人可以帮忙吗?

谢谢!

【问题讨论】:

【参考方案1】:

我设法在 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

【讨论】:

感谢您的解决方案!希望这能在某个地方得到解决。

以上是关于石墨网和 ubuntu 18.04的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu 18.04 系统U盘安装与初步设置

Ubuntu18.04网络管理

[ubuntu]ubuntu18.04清华源source.list

ubuntu 18.04设置开机级别

win10+ubuntu18.04双系统的ubuntu18.04完全卸载

ubuntu-18.04 的环境初始化配置