0

我正在尝试以与从 Windows 命令行执行它的方式相同的方式执行 metricebeat,但通过在 python 脚本中使用 subprocess.Popen。

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

尽管我执行具有相同实现的其他进程并且它们工作并且不会终止,但该进程会立即启动和终止。

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

这是我的终止条件,它总是正确的,这就是它终止的原因。

有没有办法将metricebeat作为后台进程执行?或者我可以尝试什么想法

4

1 回答 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()
于 2019-02-06T03:14:11.377 回答