Skip to content

Instantly share code, notes, and snippets.

@1f604
Last active January 22, 2022 23:21
Show Gist options
  • Save 1f604/1db5ef1dc2f438a9046f06a13e1e94f6 to your computer and use it in GitHub Desktop.
Save 1f604/1db5ef1dc2f438a9046f06a13e1e94f6 to your computer and use it in GitHub Desktop.
Launch elastic search from Python
from multiprocessing import Process
import os
import requests
from time import sleep
def f(name):
print('hello! RUNNIGN ELASTIC!', name)
os.system('ES_JAVA_OPTS="-Xms2g -Xmx2g" /home/x/elasticsearch-7.16.3/bin/elasticsearch')
def monitor():
while True:
sleep(1)
try:
r = requests.get('http://localhost:9200/_cluster/health?pretty=true')
print("=====RESPONSE:", r.json())
except:
print("!!!!!!!FAILED!")
pass
if __name__ == '__main__':
p = Process(target=f, args=('bob',))
m = Process(target=monitor)
p.start()
m.start()
p.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment