我使用gunicorn运行我的flask应用程序的2进程。
我使用filerotatingfilehandler来旋转日志文件。
问题是当一个进程旋转日志文件时,另一个进程不知道,然后它旋转文件(现在命名为日志.txt(1)再次日志.txt.2,可能会改变日志.txt至日志.txt.1)。然后一个进程登录日志.txt其他人登录时日志.txt.1.
我知道我可以使用watchedfilehandler+logrotate来解决这个问题。
但是我仍然可以使用rotatingfilehandler并检测文件名的更改吗?你知道吗
Tags:
可以使用分布式全局锁来防止双重旋转,如this example gist。你知道吗
不过,我建议您在Flask应用程序中使用WatchedFileHandler:
然后使用cron脚本或文件监视守护程序通过重命名日志文件来旋转日志文件。你知道吗
相关问题 更多 >
编程相关推荐