|
|
@@ -11,6 +11,7 @@ from nilmdb.utils.time import string_to_timestamp |
|
|
|
import cherrypy |
|
|
|
import sys |
|
|
|
import os |
|
|
|
import socket |
|
|
|
import simplejson as json |
|
|
|
import decorator |
|
|
|
import psutil |
|
|
@@ -629,17 +630,21 @@ def wsgi_application(dbpath, basepath): # pragma: no cover |
|
|
|
basepath = basepath.rstrip('/')) |
|
|
|
except Exception: |
|
|
|
# Build an error message on failure |
|
|
|
import pprint |
|
|
|
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)\n", |
|
|
|
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]) |
|
|
|
os.getgid(), grp.getgrgid(os.getgid())[0], |
|
|
|
socket.gethostname(), os.getpid()) |
|
|
|
except ImportError: |
|
|
|
pass |
|
|
|
err += sprintf("\nEnvironment:\n%s\n", pprint.pformat(environ)) |
|
|
|
if server[0] is None: |
|
|
|
# Serve up the error with our own mini WSGI app. |
|
|
|
headers = [ ('Content-type', 'text/plain'), |
|
|
|