2012-08-15 81 views
2

我创建了一个测试可执行文件,以查看是否可以捕获由Supervisord监控的程序的输出。无法获取supervisord监控进程的输出

tester.py:

#! /usr/bin/env python 

import time, os 
pid = os.getpid() 
print "EXECUTING ON %s" % pid 
while True: 
    time.sleep(5) 
    print "HOLLER %s" % pid 

supervisord.conf:

[program:mytester] 
command={path}/tester.py 

但是,当我尝试在supervisorctl运行过程中tail,什么都没有。

回答

1

这已经有一段时间,因为你问,但如果你仍然有兴趣和任何人有同样的问题:

在这种情况下,Python是缓冲输出,你不会看到它,直到刷新到标准输出。你可以强制与sys.stdout.flush()冲洗程序中的,但可能修复它的最彻底的方法是在缓冲模式-u标志Python解释器的运行脚本:

supervisord.conf

[program:mytester] 
command=python -u {path}/tester.py 

(有同样的问题,发现supervisord的mailing list解决方案)

+0

thanks-我也没有办法,现在来测试你的答案,但似乎是正确的! – Yarin 2013-07-30 12:21:10

+0

在我的情况下,所有的日志直接进入/ tmp - 例如/tmp/test_python---supervisor-Lt44XR.log。主管会忽略我在配置文件中的所有努力,将它们放在其他地方。 – patriciasz 2014-08-20 15:49:22

+0

@patriciasz,所以当你直接执行程序 - 没有supervisord被卷入时,你会得到输出到标准输出吗? – pacha 2014-08-20 18:48:11