Mohsen Mohsen - 2 months ago 14
Python Question

Setup Apache2 mod_wsgi for sentry

I already used sentry 8.1 that installed on a virtualenv by below apache configs:

<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>


and all worked correct, but after i update sentry to 8.3.3, i have problems by static files, and in apache log i see below exception:

[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'


Type of
iterable
is FileWrapper, also below packeges are currently installed in my sentry 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

Answer

I changed latest line of */my-venv/lib/python2.7/site-packages/sentry/wsgi.py as below and now worked:

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

But i think that sentry cant monitor and show internal exceptions, and in next step i changed the application variable definition line as below:

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

And i think this code working correctly.

Comments