使用Python脚本启动麋鹿服务
我正在Python中编写一个脚本,该脚本在Localhost 9200启动了Elasticsearch,Kibana Server。我在Internet上发现的所有示例都涉及到与Localhost 9200运行的现有Elasticsearch实例的连接。 我的摩托车是我想拥有一个脚本,我可以一口气开始并停止麋鹿服务器,而无需使用命令行来启动或停止服务器。
基本上,任务是
bin/elasticsearch
用Python中的某些东西替换此行。
但是,我尝试了以下内容
subprocess.Popen(path + '/elasticsearch/elasticsearch-'+version+'/bin/elasticsearch')
subprocess.Popen(path + '/kibana/kibana-'+version+'-darwin-x86_64/bin/kibana')
,但是我无法使用此代码启动服务。这是第一次开始启动,但是要杀死运行过程,我需要找到PID PF过程并通过使用手动杀死它,
kill <PID>
但是当我尝试重新启动服务时,它告诉它已经为服务创建的实例,并且它在On上启动了Elasticsearch Service另一个Localhost港口:9201和Kibana由于Elasticsearch冲突而无法开始。
提出一些开始和停止服务以完成所需任务的方法。
谁能提供一个代码片段,说明我将如何编程/自动创建Elasticsearch,Kibana服务器实例?是否有现有的项目?事先感谢您的任何帮助。
I am writing a script in python which starts an elasticsearch, kibana server at localhost 9200. All examples I found on the internet are regarding connectivity to an existing elasticsearch instance running at localhost 9200.
My moto is that I want to have a script by which I can start and stop the ELK server in one go without going to use the command line to start or stop the server.
Basically, the task is replace this line
bin/elasticsearch
with something in python.
I have tried the following
subprocess.Popen(path + '/elasticsearch/elasticsearch-'+version+'/bin/elasticsearch')
subprocess.Popen(path + '/kibana/kibana-'+version+'-darwin-x86_64/bin/kibana')
However, I am not able to start the services with this code. For first time it got started but for killing the running process I need to find the PID pf process and kill it manually by using,
kill <PID>
But when I try to restart the services it tells an instance already created for the services and it starts elasticsearch service on another port localhost:9201 and kibana fails to start due to elasticsearch conflict.
Suggest some ways to start and stop the services to achieve the task required.
Could anyone provide a code snippet of how I would go about creating the elasticsearch, kibana servers instance programmatically/automatically? Are there any existing projects that do this? Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论