Elasticsearch python 启动脚本

来源:互联网 发布:大连嘉友软件 编辑:程序博客网 时间:2024/05/18 00:29
import osimport sysdef endpcess():    nb= os.popen("jps|grep Elasticsearch").read()    oldid=nb.split(' ')[0]    #print 'oldid'+oldid    nb=os.system("kill "+oldid)    return 'Elasticsearch is end'def startprcess():    os.system("su - es -c '/home/es/es/es-2.4.4/bin/elasticsearch -d'")    #nb= os.popen("jps|grep Elasticsearch").read()    #print 'newid'+nb.split(' ')[0]    return 'Elasticsearch is start'def restartprcess():    endpcess()    startprcess()    return 'Elasticsearch is restart'if __name__ =='__main__':    try:        name=sys.argv[1]        if name=='-e':            info=endpcess()            print info        elif name=='-s':            info=startprcess()            print info        elif name=='-r':            info=restartprcess()            print info        elif name=='-h':            print 'cmd:python es.py -e  ----stop Elasticsearch service'            print 'cmd:python es.py -s  ----start Elasticsearch service'            print 'cmd:python es.py -r  ----restart Elasticsearch service'            print 'cmd:python es.py -h  ----cmd help'    except:            print 'cmd:python es.py -e  ----stop Elasticsearch service'            print 'cmd:python es.py -s  ----start Elasticsearch service'            print 'cmd:python es.py -r  ----restart Elasticsearch service'            print 'cmd:python es.py -h  ----cmd help'

原创粉丝点击