@@ -391,25 +391,32 @@ class Server(object):
# into it from separate threads.
self.embedded = embedded
self.db = nilmdb.utils.Serializer(db)
# Build up global server configuration
cherrypy.config.update({
'server.socket_host': host,
'server.socket_port': port,
'engine.autoreload_on': False,
'server.max_request_body_size': 4*1024*1024,
'error_page.default': self.json_error_page,
})
if self.embedded:
cherrypy.config.update({ 'environment': 'embedded' })
# Build up application specific configuration
app_config = {}
app_config.update({
'error_page.default': self.json_error_page,
})
# Send a permissive Access-Control-Allow-Origin (CORS) header
# with all responses so that browsers can send cross-domain
# requests to this server.
cherrypy.config.update({ 'response.headers.Access-Control-Allow-Origin':
'*' })
app_ config.update({ 'response.headers.Access-Control-Allow-Origin':
'*' })
# Send tracebacks in error responses. They're hidden by the
# error_page function for client errors (code 400-499).
cherrypy. config.update({ 'request.show_tracebacks' : True })
app_ config.update({ 'request.show_tracebacks' : True })
self.force_traceback = force_traceback
# Patch CherryPy error handler to never pad out error messages.
@@ -417,11 +424,13 @@ class Server(object):
# error messages.
cherrypy._cperror._ie_friendly_error_sizes = {}
cherrypy.tree.apps = {}
cherrypy.tree.mount(Root(self.db, self.version), "/" )
cherrypy.tree.mount(Stream(self.db), "/stream" )
# Build up the application and mount it
root = Root(self.db, self.version )
root.stream = Stream(self.db )
if stoppable:
cherrypy.tree.mount(Exiter(), "/exit")
root.exit = Exiter()
cherrypy.tree.apps = {}
cherrypy.tree.mount(root, "/", config = { "/" : app_config })
# Shutdowns normally wait for clients to disconnect. To speed
# up tests, set fast_shutdown = True