我试图执行metricebeat我从Windows命令行执行同样的方式,而是由在Python脚本使用subprocess.Popen。
subprocess.Popen(["C:\metricbeat\metricbeat.exe"])
该过程开始,虽然我执行与相同的实现其他进程和他们的工作并没有结束立即终止。
self.process.poll()
if self.process.returncode is not None:
self.Shutdown()
这是我的终止条件,它总是真实的,这就是为什么它终止。
有没有执行metricebeat作为后台进程的方法吗?或者有什么想法,我可以尝试
你应该使用:
os.popen("Powershell.exe", 'C:\metricbeat\metricbeat -e -c C:\metricbeat\metricbeat.yml', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()