Python-Supervisor如何记录标准输出-
我不是python方面的专家,有人能解释一下问题出在哪里吗 我想通过主管来取样品 我制作了3个不同的脚本来打印输出,对于bash和PHP,我可以收集输出,没有问题,python无法工作 php_test.shPython-Supervisor如何记录标准输出-,python,linux,python-3.x,unix,supervisord,Python,Linux,Python 3.x,Unix,Supervisord,我不是python方面的专家,有人能解释一下问题出在哪里吗 我想通过主管来取样品 我制作了3个不同的脚本来打印输出,对于bash和PHP,我可以收集输出,没有问题,python无法工作 php_test.sh #!/usr/bin/php <?php for($i=0;$i<100000;$i++){ sleep(5); echo 'test'; } ?> python_test.sh(使用不同的测试打印输出) 我的主管配置文
#!/usr/bin/php
<?php
for($i=0;$i<100000;$i++){
sleep(5);
echo 'test';
}
?>
python_test.sh(使用不同的测试打印输出)
我的主管配置文件
猛击
php
蟒蛇
[program:python_test]
process_name=python_test
command=/home/user/python_test.sh
stdout_logfile=/home/user/python_test_output.log
stdout_logfile_maxbytes=0
非常感谢你的帮助。
它快把我逼疯了;[Python输出已缓冲,请在打印后使用此选项
sys.stdout.flush()
或(Python 3)
或者更好
import logging
logging.warning('Watch out!')
您还可以使用
pip install supervisor stdout安装stdout友好版本
。查找使用说明
更新:
您还可以更新supervisord.conf
以将输出指向stdout
[program:worker2]
command=bash yourscript.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
这两个输出都不工作?PHP和BASH工作正常,Python不打印任何内容。如果我使用
python3./Python_test.sh
执行脚本,我可以在控制台中看到输出,但不能在主管日志中看到输出;(这节省了我的时间,谢谢!
[program:python_test]
process_name=python_test
command=/home/user/python_test.sh
stdout_logfile=/home/user/python_test_output.log
stdout_logfile_maxbytes=0
sys.stdout.flush()
print(something, flush=True)
import logging
logging.warning('Watch out!')
[program:worker2]
command=bash yourscript.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0