예제 #1
0
def es_process(es_binary, es_version):
    port = port_for.select_random()
    pid = es_binary + '.pid'

    # use a different garbage collector for better performance
    os.environ['ES_JAVA_OPTS'] = \
        '-Xms1g -Xmx1g -XX:-UseConcMarkSweepGC -XX:+UseG1GC'

    command = (
        f"{es_binary} -p {pid} -E http.port={port} "
        f"-E xpack.monitoring.enabled=false "
        f"-E xpack.monitoring.collection.enabled=false "
        f"> /dev/null"
    )

    url = f'http://127.0.0.1:{port}/_cluster/health?wait_for_status=green'

    executor = HTTPExecutor(command, url, method='GET', shell=True)
    executor.start()

    yield executor

    executor.stop()
    executor.kill()