Exemple #1
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()
Exemple #2
0
def _wait_for_mongo_db_server(mongo_url, timeout):
    start_time = time.time()

    while not is_db_server_up(mongo_url):
        logger.info(f"Waiting for MongoDB server on {mongo_url}")

        if (time.time() - start_time) > timeout:
            raise MongoDBTimeOutError(
                f"Failed to connect to MongoDB after {timeout} seconds.")

        time.sleep(1)
Exemple #3
0
def wait_for_mongo_db_server(mongo_url):
    while not is_db_server_up(mongo_url):
        logger.info('Waiting for MongoDB server on {0}'.format(mongo_url))
        time.sleep(1)