|
|
@@ -501,7 +501,7 @@ class Server(object): |
|
|
|
# work, the web server must use only a single process and single |
|
|
|
# Python interpreter. Multiple threads are OK. |
|
|
|
_wsgi_server = None |
|
|
|
def wsgi_application(dbpath, basepath): # pragma: no cover |
|
|
|
def wsgi_application(dbpath, basepath): |
|
|
|
"""Return a WSGI application object with a database at the |
|
|
|
specified path. |
|
|
|
|
|
|
@@ -526,23 +526,21 @@ def wsgi_application(dbpath, basepath): # pragma: no cover |
|
|
|
err = sprintf("Initializing database at path '%s' failed:\n\n", |
|
|
|
dbpath) |
|
|
|
err += traceback.format_exc() |
|
|
|
try: |
|
|
|
import pwd |
|
|
|
import grp |
|
|
|
err += sprintf("\nRunning as: uid=%d (%s), gid=%d (%s) " |
|
|
|
"on host %s, pid %d\n", |
|
|
|
os.getuid(), pwd.getpwuid(os.getuid())[0], |
|
|
|
os.getgid(), grp.getgrgid(os.getgid())[0], |
|
|
|
socket.gethostname(), os.getpid()) |
|
|
|
except ImportError: |
|
|
|
pass |
|
|
|
import pwd |
|
|
|
import grp |
|
|
|
err += sprintf("\nRunning as: uid=%d (%s), gid=%d (%s) " |
|
|
|
"on host %s, pid %d\n", |
|
|
|
os.getuid(), pwd.getpwuid(os.getuid())[0], |
|
|
|
os.getgid(), grp.getgrgid(os.getgid())[0], |
|
|
|
socket.gethostname(), os.getpid()) |
|
|
|
err += sprintf("\nEnvironment:\n%s\n", pprint.pformat(environ)) |
|
|
|
if _wsgi_server is None: |
|
|
|
# Serve up the error with our own mini WSGI app. |
|
|
|
headers = [ ('Content-type', 'text/plain'), |
|
|
|
('Content-length', str(len(err))) ] |
|
|
|
err_b = err.encode('utf-8') |
|
|
|
headers = [ ('Content-type', 'text/plain; charset=utf-8'), |
|
|
|
('Content-length', str(len(err_b))) ] |
|
|
|
start_response("500 Internal Server Error", headers) |
|
|
|
return [err] |
|
|
|
return [err_b] |
|
|
|
|
|
|
|
# Call the normal application |
|
|
|
return _wsgi_server.wsgi_application(environ, start_response) |
|
|
|