【发布时间】:2012-12-05 18:24:53
【问题描述】:
我有一个 [program:x] 正在运行,它会打印 /sys.stdout.writes 很多东西。在 [supervisord] 的 AUTO childlogdir 或 [program:x] 的 stdout_logfile 中都没有出现 我错过了什么吗?
如何捕获从 [program:x] 打印或标准输出的所有内容?
在我的程序中,我明确地同时做这两件事,
print "something"
sys.stdout.write("something")
相关的supervisord.conf文件
[supervisord]
childlogdir = %(here)s/../logs/supervisord/
logfile = %(here)s/../logs/supervisord/supervisord.log
logfile_maxbytes = 100MB
logfile_backups = 10
loglevel = info
pidfile = %(here)s/../logs/supervisord/supervisord.pid
umask = 022
nodaemon = false
nocleanup = false
[program:x]
directory = %(here)s/../
command = python file.py
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile = /appropriate-path/to/access.log
【问题讨论】:
-
您确定程序打印到
stdout而不是stderr? -
用更多信息编辑了问题。当我执行 sys.stdout.write 时,它应该打印到标准输出
-
那
[program:..]的supervisord 配置是什么?哦,试试sys.stdout.flush()以确保它不是缓冲区。 -
我把整个conf文件放进去。另外,我尝试在 file.py 的末尾添加
sys.stdout.flush(),但没有成功。 -
如果你检查你的supervisord日志文件,你真的看到你的进程已经启动了吗?如果程序从未运行过,它就不能输出任何东西。
标签: python logging supervisord