Esempio n. 1
0
def _init_cluster(data_dir=None, *, cleanup_atexit=True, init_settings=None):
    if init_settings is None:
        init_settings = {}
    if (not os.environ.get('EDGEDB_DEBUG_SERVER')
            and not os.environ.get('EDGEDB_LOG_LEVEL')):
        _env = {'EDGEDB_LOG_LEVEL': 'silent'}
    else:
        _env = {}

    if data_dir is None:
        cluster = edgedb_cluster.TempCluster(env=_env, testmode=True)
        destroy = True
    else:
        cluster = edgedb_cluster.Cluster(data_dir=data_dir, env=_env)
        destroy = False

    if cluster.get_status() == 'not-initialized':
        cluster.init(server_settings=init_settings)

    cluster.start(port='dynamic')
    cluster.set_superuser_password('test')

    if cleanup_atexit:
        atexit.register(_shutdown_cluster, cluster, destroy=destroy)

    return cluster
Esempio n. 2
0
def _init_cluster(data_dir=None, *, pg_cluster=None,
                  cleanup_atexit=True, init_settings={}):
    if (not os.environ.get('EDGEDB_DEBUG_SERVER') and
            not os.environ.get('EDGEDB_LOG_LEVEL')):
        _env = {'EDGEDB_LOG_LEVEL': 'silent'}
    else:
        _env = {}

    if data_dir is None:
        cluster = edgedb_cluster.TempCluster(env=_env)
        destroy = True
    else:
        cluster = edgedb_cluster.Cluster(
            data_dir=data_dir, postgres_cluster=pg_cluster, env=_env)
        destroy = False

    if cluster.get_status() == 'not-initialized':
        cluster.init(server_settings=init_settings)

    cluster.start(port='dynamic', timezone='UTC')

    if cleanup_atexit:
        atexit.register(_shutdown_cluster, cluster, destroy=destroy)

    return cluster