为哨兵设置Apache2 mod_wsgi

时间:2016-05-01 16:51:32

标签: python django wsgi sentry

我已经在apache configs上使用了安装在virtualenv上的哨兵8.1:

<VirtualHost x.x.x.x:80>
        WSGIDaemonProcess sentry python-path=/var/www/sentry-me:/var/www/sentry-me/env/lib/python2.7/site-packages
        WSGIProcessGroup sentry
        WSGIScriptAlias / /var/www/sentry-me/env/lib/python2.7/site-packages/sentry/wsgi.py
</VirtualHost>

并且所有工作都正确,但在我将sentry更新到8.3.3之后,我遇到了静态文件的问题,在apache日志中我看到了以下异常:

[Sun May 01 16:38:46.106931 2016] [wsgi:error] [pid 19046] [remote 5.39.50.57:27319] Traceback (most recent call last):
[Sun May 01 16:38:46.106960 2016] [wsgi:error] [pid 19046] [remote 5.39.50.57:27319]   File "/var/www/sentry-me/env/lib/python2.7/site-packages/raven/middleware.py", line 48, in __call__
[Sun May 01 16:38:46.107006 2016] [wsgi:error] [pid 19046] [remote 5.39.50.57:27319]     for event in iterable:
[Sun May 01 16:38:46.107043 2016] [wsgi:error] [pid 19046] [remote 5.39.50.57:27319] KeyError: 'file like object has no read() method'

iterable的类型是FileWrapper,下面的包装当前也安装在我的哨兵virtualenv中:

amqp==1.4.9
anyjson==0.3.3
BeautifulSoup==3.2.1
billiard==3.3.0.23
celery==3.1.18
cffi==1.6.0
click==6.6
contextlib2==0.5.1
cryptography==1.3.1
cssselect==0.9.1
cssutils==0.9.10
Django==1.6.11
django-bitfield==1.7.1
django-crispy-forms==1.4.0
django-debug-toolbar==1.3.2
django-jsonfield==0.9.13
django-paging==0.2.5
django-picklefield==0.3.2
django-recaptcha==1.0.5
django-social-auth==0.7.28
django-sudo==1.2.1
django-templatetag-sugar==1.0
djangorestframework==2.3.14
email-reply-parser==0.2.0
enum34==1.1.4
exam==0.10.5
hiredis==0.1.6
httplib2==0.9.2
idna==2.1
ipaddr==2.1.11
ipaddress==1.0.16
kombu==3.0.30
lxml==3.6.0
mock==1.0.1
ndg-httpsclient==0.4.0
oauth2==1.9.0.post1
petname==1.7
progressbar==2.3
psycopg2==2.6.1
py==1.4.31
pyasn1==0.1.9
pycparser==2.14
pyOpenSSL==16.0.0
pytest==2.6.4
pytest-django==2.9.1
python-dateutil==2.5.3
python-memcached==1.57
python-openid==2.2.5
pytz==2016.4
PyYAML==3.11
raven==5.13.0
rb==1.4
redis==2.10.5
requests==2.9.2
sentry==8.3.3
setproctitle==1.1.9
simplejson==3.8.2
six==1.10.0
South==1.0.1
sqlparse==0.1.19
statsd==3.1
toronado==0.0.7
ua-parser==0.7.0
urllib3==1.14
uWSGI==2.0.12

1 个答案:

答案 0 :(得分:1)

我更改了*/my-venv/lib/python2.7/site-packages/sentry/wsgi.py的最新行,如下所示,现在有效:

application = WSGIHandler()  # Sentry(FileWrapperWSGIHandler())

但我认为哨兵不能监视并显示内部异常,并且在下一步中我更改了application变量定义行,如下所示:

application = Sentry(WSGIHandler())  # Sentry(FileWrapperWSGIHandler())

我觉得这段代码工作正常。