|
|
@@ -4,14 +4,17 @@ import nilmdb.server |
|
|
|
import argparse |
|
|
|
import os |
|
|
|
import socket |
|
|
|
import cherrypy |
|
|
|
|
|
|
|
def main(): |
|
|
|
"""Main entry point for the 'nilmdb-server' command line script""" |
|
|
|
|
|
|
|
parser = argparse.ArgumentParser( |
|
|
|
description = 'Run the NilmDB server', |
|
|
|
formatter_class = argparse.ArgumentDefaultsHelpFormatter, |
|
|
|
version = nilmdb.__version__) |
|
|
|
formatter_class = argparse.ArgumentDefaultsHelpFormatter) |
|
|
|
|
|
|
|
parser.add_argument("-v", "--version", action="version", |
|
|
|
version = nilmdb.__version__) |
|
|
|
|
|
|
|
group = parser.add_argument_group("Standard options") |
|
|
|
group.add_argument('-a', '--address', |
|
|
@@ -39,6 +42,8 @@ def main(): |
|
|
|
db = nilmdb.utils.serializer_proxy(nilmdb.server.NilmDB)(args.database) |
|
|
|
|
|
|
|
# Configure the server |
|
|
|
if not args.quiet: |
|
|
|
cherrypy._cpconfig.environments['embedded']['log.screen'] = True |
|
|
|
server = nilmdb.server.Server(db, |
|
|
|
host = args.address, |
|
|
|
port = args.port, |
|
|
@@ -64,10 +69,12 @@ def main(): |
|
|
|
server.start(blocking = True) |
|
|
|
finally: |
|
|
|
yappi.stop() |
|
|
|
yappi.print_stats(sort_type = yappi.SORTTYPE_TTOT, limit = 50) |
|
|
|
stats = yappi.get_func_stats() |
|
|
|
stats.sort("ttot") |
|
|
|
stats.print_all() |
|
|
|
from IPython import embed |
|
|
|
embed(header = "Use the yappi object to explore further, " |
|
|
|
"quit to exit") |
|
|
|
embed(header = "Use the `yappi` or `stats` object to explore " |
|
|
|
"further, quit to exit") |
|
|
|
else: |
|
|
|
server.start(blocking = True) |
|
|
|
|
|
|
|