Ejemplo n.º 1
0
def start():
    """
    Used from __main__ to start as simple flask app
    :return:
    """
    parser = argparse.ArgumentParser(description='monitor_exporter')

    parser.add_argument('-f',
                        '--configfile',
                        dest="configfile",
                        help="configuration file")

    parser.add_argument('-p', '--port', dest="port", help="Server port")

    args = parser.parse_args()

    port = 9631

    config_file = 'config.yml'
    if args.configfile:
        config_file = args.configfile

    configuration = config.read_config(config_file)
    if 'port' in configuration:
        port = configuration['port']

    if args.port:
        port = args.port

    log.configure_logger(configuration)

    monitorconnection.MonitorConfig(configuration)
    # Need to create a event loop for apscheduler
    loop = asyncio.new_event_loop()
    # Set the event loop
    asyncio.set_event_loop(loop)

    start_scheduler(configuration)

    log.info(f"Starting web app on port {port}")

    app = Quart(__name__)

    app.register_blueprint(proxy.app, url_prefix='')

    # Use the existing event loop
    app.run(host='0.0.0.0', port=port, loop=loop)
Ejemplo n.º 2
0
def start():
    """
    Used from __main__ to start as simple flask app
    :return:
    """
    parser = argparse.ArgumentParser(description='monitor_exporter')

    parser.add_argument('-f',
                        '--configfile',
                        dest="configfile",
                        help="configuration file")

    parser.add_argument('-p', '--port', dest="port", help="Server port")

    args = parser.parse_args()

    port = 9631

    config_file = 'config.yml'
    if args.configfile:
        config_file = args.configfile

    configuration = config.read_config(config_file)
    if 'port' in configuration:
        port = configuration['port']

    if args.port:
        port = args.port

    log.configure_logger(configuration)
    ##

    monitorconnection.MonitorConfig(configuration)
    log.info('Starting web app on port: ' + str(port))

    app = Flask(__name__)

    app.register_blueprint(proxy.app, url_prefix='/')
    app.run(host='0.0.0.0', port=port)
Ejemplo n.º 3
0
def create_app(config_path=None):
    """
    Used typical from gunicorn if need to pass config file different from default, e.g.
    gunicorn -b localhost:5000 --access-logfile /dev/null -w 4 "wsgi:create_app('/tmp/config.yml')"
    :param config_path:
    :return:
    """
    config_file = 'config.yml'
    if config_path:
        config_file = config_path

    configuration = config.read_config(config_file)

    log.configure_logger(configuration)

    monitorconnection.MonitorConfig(configuration)
    log.info('Starting web app')

    app = Flask(__name__)

    app.register_blueprint(proxy.app, url_prefix='/')

    return app