我目前正在使用supervisor轻松地监视和守护一些python脚本。然而,似乎主管无法正确记录。
我正在执行的脚本非常简单:#!/usr/bin/env python
import pushybullet as pb
import sys, time, logging
# INIT LOGGING
logging.basicConfig(format='%(asctime)s @%(name)s [%(levelname)s]: %(message)s', level = logging.DEBUG)
if __name__ == '__main__':
try:
logging.info('Custom service started')
while True:
#here for the sake of example, actually doing real stuff here
time.sleep(2)
finally:
logging.info('Custom service stopped')
下面是相应的conf文件:
^{pr2}$
所以我在谷歌上做了很多研究。
用print替换日志记录行,然后刷新stdout索引项,这与-u选项相同,可以启动脚本。但是打印并不能满足我的需要,Python的日志模块是。所以我试着在每个日志行之后刷新,并在unbuffered mod中启动脚本,但是什么也没有出现!
提前感谢您的帮助!