Changeset 1415 for trunk/pylucid/index.fcgi
- Timestamp:
- 02/15/08 17:08:59 (2 years ago)
- Files:
-
- 1 modified
-
trunk/pylucid/index.fcgi (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/index.fcgi
r1413 r1415 16 16 -You need the python package "flup": http://trac.saddi.com/flup 17 17 18 Debugging help 19 ~~~~~~~~~~~~~~ 20 If you only see something like 21 - "FastCGI Unhandled Exception" 22 - "Internal Server Error" 23 - "Premature end of script headers" 24 try this: 25 - Set a LOGFILE 26 - use the runfastcgi() options: 27 daemonize="false" 28 maxrequests=1 29 - Use ./tests/server_tests/fastCGI_test.fcgi 30 - Try to turn on the flup traceback, see: 31 http://code.djangoproject.com/ticket/6610 32 18 33 Last commit info: 19 34 ~~~~~~~~~~~~~~~~~ … … 25 40 :license: GNU GPL v3, see LICENSE.txt for more details. 26 41 """ 27 import sys, os 42 import sys, os, time 43 44 start_overall = time.time() 28 45 29 46 # Logging … … 41 58 os.environ['DJANGO_SETTINGS_MODULE'] = "PyLucid.settings" 42 59 60 # Global variable for the last traceback: 61 last_tb_info = None 43 62 44 63 #______________________________________________________________________________ … … 54 73 ) 55 74 log = logging.debug 56 log(" Logging started")75 log("--- Logging started ---") 57 76 else: 58 77 # No logging … … 83 102 log("StdErrorHandler error: %s" % e) 84 103 85 86 104 #______________________________________________________________________________ 87 105 … … 90 108 """ Minimalistic WSGI app for debugging """ 91 109 start_response('200 OK', [('Content-Type', 'text/html')]) 92 yield '<h1>FastCGI Traceback catch :</h1>'110 yield '<h1>FastCGI Traceback catch</h1>' 93 111 112 # Display the overall running time 113 yield 'overall time: %.2fsec' % (time.time() - start_overall) 114 115 # Display the last traceback 116 yield '<h2>last_tb_info:</h2>' 94 117 try: 95 import traceback 96 yield "<pre>%s</pre>" % traceback.format_exc() 118 yield "<pre>%s</pre>" % last_tb_info 97 119 except Exception, e: 98 120 yield "Traceback error: %s" % e 99 121 122 yield '<hr />' 123 100 124 from cgi import escape 101 yield '<h r /><h1>FastCGI Environment</h1><table>'125 yield '<h1>FastCGI Environment</h1><table>' 102 126 for k, v in sorted(environ.items()): 103 127 yield '<tr><th>%s</th><td>%s</td></tr>' % ( 104 128 escape(repr(k)), escape(repr(v)) 105 129 ) 106 130 yield '</table>' 107 131 108 132 #______________________________________________________________________________ … … 135 159 #method="prefork", # prefork or threaded (default prefork) 136 160 #daemonize="false", # Bool, whether to detach from terminal 137 maxrequests=1, # number of requests a child handles before it is161 #maxrequests=1, # number of requests a child handles before it is 138 162 # killed and a new child is forked (0 = no limit) 139 163 #maxspare=2, # max number of spare processes/threads 140 164 #maxchildren=2 # hard limit number of processes/threads 165 #debug=True, # Not Implemented, see: 166 # http://code.djangoproject.com/ticket/6610 141 167 ) 142 168 except SystemExit, e: … … 144 170 except Exception, e: 145 171 log("fastCGI error: %s" % e) 172 import sys, traceback 173 last_tb_info = traceback.format_exc() 174 log(last_tb_info) 146 175 from flup.server.fcgi import WSGIServer 147 176 WSGIServer(tb_catch_app).run()