コード例 #1
0
def start_server():
    """ start the web server """
    logging.info("starting on port {0}".format(options.port))
    # make site configuration available in the Application settings
    config = deploy.get_server_config(options.config)
    modules = [dashboard.reports]
    if options.imports:
        extra_module_names = options.imports.split(',')
        for name in extra_module_names:
            try:
                mod = importlib.import_module(name)
                modules.append(mod)
                dashboard.reports.Version.register(name, mod.version)
            except (ImportError, AttributeError) as e:
                logging.warning("Unable to import '{}': {}".format(name, e))
    # when running stand-alone, provide /app/version
    urls = [(r"/app/version", dashboard.reports.Version)]
    for module in modules:
        urls += urls_from_module(module)
    app = web.Application(urls, config=config)
    # make IOLoop quieter about unimportant exceptions
    tsumanga.ioloop.quiet_patch()
    app.listen(options.port)
    try:
        ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        return # no annoying traceback while testing
コード例 #2
0
ファイル: distimo.py プロジェクト: Tsumanga-Studios/dashboard
def init():
    """ set up distimo keys """
    global DISTIMO_KEYS
    if DISTIMO_KEYS:
        return
    try:
        server = tornado.options.options.config
    except AttributeError:
        server = "local"
    config = deploy.get_server_config(server)
    distimo_keys = config.getlist("distimo_keys", "")
    if len(distimo_keys) != 4:
        logging.warning("distimo_keys in config should be private, public, username, base64auth ")
        raise WebServiceError(500, mesg="distimo not configured")
    DISTIMO_KEYS = tuple(distimo_keys)
コード例 #3
0
def start_server():
    """ start the web server """
    logging.info("starting on port {0}".format(options.port))
    if options.static == "here":
        static_path = os.path.join(HERE, "static")
    else:
        static_path = options.static
    template_path = os.path.join(HERE, "templates")
    logging.info("templates are in {0}".format(template_path))
    # make site configuration available in the Application settings
    config = deploy.get_server_config(options.config)
    modules = [dashboard.pages]
    if options.imports:
        extra_module_names = options.imports.split(',')
        for name in extra_module_names:
            try:
                modules.append(importlib.import_module(name))
            except ImportError:
                logging.warning("can't import {0}".format(name))
                pass
    urls = []
    for module in modules:
        urls += urls_from_module(module)
    app = web.Application(
        urls,
        template_path=template_path,
        static_path=static_path,
        static_handler_class=SafeStaticHandler,
        cookie_secret=b'htmlasagne',
        config=config,
        ui_modules=dashboard.ui_modules,
        gzip=True)

    # make IOLoop quieter about unimportant exceptions
    tsumanga.ioloop.quiet_patch()

    # run on chosen port
    app.listen(options.port, xheaders=True)
    try:
        ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        return # no annoying traceback while testing