0

Background:

I have an OpenShift Python 2.7 gear containing my Django 1.6 application. I used django-openshift-quickstart.git as a starting point for my own project and it works well.

However, if I have a syntax error in my code or some other exception I have no way of finding it. I can do a tail of the logs via:

rhc tail -a appname

However, this only shows me that a 500 error occurred. I never see any exceptions or details other than:

10.137.24.60, x.x.x.x - - [13/Nov/2014:17:12:27 -0500] "GET /snapper/snapshots HTTP/1.1" 500 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"

The client web browser reports:

Server Error (500)

I turned on the DEBUG setting (DEBUG = True) in my settings.py but that made no difference. I still see no exceptions in the logs or in the browser.

I believe the container (gear) is using haproxy + apache + mod_wsgi + python2.7.

I'd dearly love to start getting Django exceptions reporting to my browser.

Question:

Why do I not see Django exceptions in my browser (or log files) under OpenShift when DEBUG is set to True ?

I realise this appears similar to the existing question How to debug Django exceptions in OpenShift applications but "rhc tail -a" simply displays the 500 error lines - I still see no Django exceptions.

AtDhVaAnNkCsE

Doug

Community
  • 1
  • 1
Doug
  • 1
  • 1
  • 3

2 Answers2

1

I don't know zilch about OpenShift, but

  1. you may have to configure your loggers (https://docs.djangoproject.com/en/1.6/topics/logging/#configuring-logging) and
  2. you have to restart the wsgi processes when you make some changes to your settings.

Now I strongly advise you to NOT set DEBUG=True on a production server - with a properly configured logger and SMTP server you should get all unhandled exceptions by mail.

As a last point: if you have something like a syntax error or such, you may not even get to the point where Django can do any logging. In this case what info you can get is up to the server process itself. BUT there's no reason you should get a SyntaxError on a production server anyway, cause you shouldn't be editing code on production...

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
  • The application works perfectly, when run locally, under _manage.py runserver_ with exceptions being reported via the browser. I believe this is specific to OpenShift and, perhaps, the way the gears combine haproxy + apache + mod_wsgi + python. I know very well that DEBUG=True is not for production. This is a proof of concept app based on django-openshift-quickstart.git and will never go to production. – Doug Nov 13 '14 at 10:49
  • @Doug sorry for the useless advices then. – bruno desthuilliers Nov 13 '14 at 13:01
  • no need to be sorry, the advice about running under DEBUG=True is good general advice. – Doug Nov 16 '14 at 21:49
0

To my horror... it turns out I simply hadn't set DEBUG=True! I could have sworn I had set it in settings.py at some point but my commit history strongly suggests I'm wrong.

With DEBUG=True in my wsgi/settings.py I can now debug my application on OpenShift.

Apologies for the noise.

Doug

Doug
  • 1
  • 1
  • 3