而使用subprocess.Popen(如何执行metricbeat)

问题描述 投票:0回答:1

我试图执行metricebeat我从Windows命令行执行同样的方式,而是由在Python脚本使用subprocess.Popen。

   subprocess.Popen(["C:\metricbeat\metricbeat.exe"])

该过程开始,虽然我执行与相同的实现其他进程和他们的工作并没有结束立即终止。

    self.process.poll()
        if self.process.returncode is not None:
            self.Shutdown()

这是我的终止条件,它总是真实的,这就是为什么它终止。

有没有执行metricebeat作为后台进程的方法吗?或者有什么想法,我可以尝试

python elastic-stack elastic-beats
1个回答
0
投票

你应该使用:

os.popen("Powershell.exe", 'C:\metricbeat\metricbeat -e -c C:\metricbeat\metricbeat.yml', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
© www.soinside.com 2019 - 2024. All rights reserved.