コード例 #1
0
ファイル: test_rest.py プロジェクト: skg-net/suzieq
def app_initialize():
    '''Initialize the test server'''

    # pylint: disable=import-outside-toplevel
    from suzieq.restServer.query import app_init

    cfgfile = create_dummy_config_file(
        datadir='./tests/data/multidc/parquet-out')
    app_init(cfgfile)
    yield
    os.remove(cfgfile)
コード例 #2
0
def rest_main(args=None):

    if args is None:
        args = sys.argv
    parser = argparse.ArgumentParser(args)
    parser.add_argument("-c",
                        "--config",
                        type=str,
                        help="alternate config file",
                        default=f'{os.getenv("HOME")}/.suzieq/suzieq-cfg.yml')
    userargs = parser.parse_args()
    app = app_init(userargs.config)
    cfg = load_sq_config(config_file=userargs.config)
    try:
        api_key = cfg['rest']['API_KEY']
    except KeyError:
        print('missing API_KEY in config file')
        exit(1)

    logcfg, loglevel = get_log_config_level(cfg)
    ssl_keyfile, ssl_certfile = get_cert_files(cfg)

    srvr_addr = cfg.get('rest', {}).get('address', '127.0.0.1')
    srvr_port = cfg.get('rest', {}).get('port', 8000)

    uvicorn.run(app,
                host=srvr_addr,
                port=srvr_port,
                log_level=loglevel.lower(),
                log_config=logcfg,
                ssl_keyfile=ssl_keyfile,
                ssl_certfile=ssl_certfile)
コード例 #3
0
ファイル: test_rest.py プロジェクト: NilashishC/suzieq
def start_server():

    from suzieq.restServer.query import app_init

    app_init(create_config())
コード例 #4
0
    del (log_config['handlers']['access']['stream'])
    log_config['handlers']['default']['filename'] = get_log_file(cfg)
    del (log_config['handlers']['default']['stream'])

    return log_config


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-c",
                        "--config",
                        type=str,
                        help="alternate config file",
                        default=f'{os.getenv("HOME")}/.suzieq/suzieq-cfg.yml')
    userargs = parser.parse_args()
    app = app_init(userargs.config)
    cfg = load_sq_config(userargs.config)
    try:
        api_key = cfg['API_KEY']
    except KeyError:
        print('missing API_KEY in config file')
        exit(1)
    log_level = cfg.get('logging-level', 'INFO').lower()
    ssl_keyfile, ssl_certfile = get_cert_files(cfg)

    uvicorn.run(app,
                host="0.0.0.0",
                port=8000,
                log_level=log_level,
                log_config=get_log_config(cfg),
                ssl_keyfile=ssl_keyfile,