Ejemplo n.º 1
0
def start_island_server(should_setup_only):
    from tornado.httpserver import HTTPServer
    from tornado.ioloop import IOLoop
    from tornado.wsgi import WSGIContainer

    mongo_url = os.environ.get('MONGO_URL', env_singleton.env.get_mongo_url())
    wait_for_mongo_db_server(mongo_url)
    assert_mongo_db_version(mongo_url)

    populate_exporter_list()
    app = init_app(mongo_url)

    crt_path = str(Path(MONKEY_ISLAND_ABS_PATH, 'cc', 'server.crt'))
    key_path = str(Path(MONKEY_ISLAND_ABS_PATH, 'cc', 'server.key'))

    setup()

    if should_setup_only:
        logger.warning("Setup only flag passed. Exiting.")
        return

    if env_singleton.env.is_debug():
        app.run(host='0.0.0.0', debug=True, ssl_context=(crt_path, key_path))
    else:
        http_server = HTTPServer(WSGIContainer(app),
                                 ssl_options={
                                     'certfile':
                                     os.environ.get('SERVER_CRT', crt_path),
                                     'keyfile':
                                     os.environ.get('SERVER_KEY', key_path)
                                 })
        http_server.listen(env_singleton.env.get_island_port())
        log_init_info()
        IOLoop.instance().start()
Ejemplo n.º 2
0
def _start_island_server(should_setup_only,
                         config_options: IslandConfigOptions):
    populate_exporter_list()
    app = init_app(mongo_setup.MONGO_URL)

    if should_setup_only:
        logger.warning("Setup only flag passed. Exiting.")
        return

    bootloader_server_thread = _start_bootloader_server()

    logger.info(
        f"Using certificate path: {config_options.crt_path}, and key path: "
        f"{config_options.key_path}.")

    if env_singleton.env.is_debug():
        app.run(
            host="0.0.0.0",
            debug=True,
            ssl_context=(config_options.crt_path, config_options.key_path),
        )
    else:
        http_server = WSGIServer(
            ("0.0.0.0", env_singleton.env.get_island_port()),
            app,
            certfile=config_options.crt_path,
            keyfile=config_options.key_path,
            log=logger,
            error_log=logger,
        )
        _log_init_info()
        http_server.serve_forever()

    bootloader_server_thread.join()
Ejemplo n.º 3
0
def start_island_server(should_setup_only):

    mongo_url = os.environ.get('MONGO_URL', env_singleton.env.get_mongo_url())
    wait_for_mongo_db_server(mongo_url)
    assert_mongo_db_version(mongo_url)

    populate_exporter_list()
    app = init_app(mongo_url)

    crt_path = str(Path(MONKEY_ISLAND_ABS_PATH, 'cc', 'server.crt'))
    key_path = str(Path(MONKEY_ISLAND_ABS_PATH, 'cc', 'server.key'))

    setup()

    if should_setup_only:
        logger.warning("Setup only flag passed. Exiting.")
        return

    if env_singleton.env.is_debug():
        app.run(host='0.0.0.0', debug=True, ssl_context=(crt_path, key_path))
    else:
        http_server = WSGIServer(
            ('0.0.0.0', env_singleton.env.get_island_port()),
            app,
            certfile=os.environ.get('SERVER_CRT', crt_path),
            keyfile=os.environ.get('SERVER_KEY', key_path))
        log_init_info()
        http_server.serve_forever()
Ejemplo n.º 4
0
def main():
    from tornado.wsgi import WSGIContainer
    from tornado.httpserver import HTTPServer
    from tornado.ioloop import IOLoop

    mongo_url = os.environ.get('MONGO_URL', env.get_mongo_url())

    while not is_db_server_up(mongo_url):
        logger.info('Waiting for MongoDB server')
        time.sleep(1)

    populate_exporter_list()
    app = init_app(mongo_url)
    if env.is_debug():
        app.run(host='0.0.0.0',
                debug=True,
                ssl_context=('monkey_island/cc/server.crt',
                             'monkey_island/cc/server.key'))
    else:
        http_server = HTTPServer(
            WSGIContainer(app),
            ssl_options={
                'certfile':
                os.environ.get('SERVER_CRT', 'monkey_island/cc/server.crt'),
                'keyfile':
                os.environ.get('SERVER_KEY', 'monkey_island/cc/server.key')
            })
        http_server.listen(env.get_island_port())
        logger.info('Monkey Island Server is running on https://{}:{}'.format(
            local_ip_addresses()[0], env.get_island_port()))

        IOLoop.instance().start()
Ejemplo n.º 5
0
def main():
    from tornado.wsgi import WSGIContainer
    from tornado.httpserver import HTTPServer
    from tornado.ioloop import IOLoop

    mongo_url = os.environ.get('MONGO_URL', env.get_mongo_url())
    wait_for_mongo_db_server(mongo_url)
    assert_mongo_db_version(mongo_url)

    populate_exporter_list()
    app = init_app(mongo_url)

    crt_path = os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', 'server.crt')
    key_path = os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', 'server.key')

    if env.is_debug():
        app.run(host='0.0.0.0', debug=True, ssl_context=(crt_path, key_path))
    else:
        http_server = HTTPServer(WSGIContainer(app),
                                 ssl_options={'certfile': os.environ.get('SERVER_CRT', crt_path),
                                              'keyfile': os.environ.get('SERVER_KEY', key_path)})
        http_server.listen(env.get_island_port())
        log_init_info()
        IOLoop.instance().start()