【发布时间】:2014-07-17 09:39:59
【问题描述】:
最近,当我尝试重新启动我的 buildmaster 时,由于 http.log 的一些问题,它失败了。我收到以下错误:
2014-07-17 11:21:55+0200 [-] RotateLogSite starting on 8000
2014-07-17 11:21:55+0200 [-] Starting factory <buildbot.status.web.baseweb.RotateLogSite instance at 0x0295F300>
2014-07-17 11:21:55+0200 [-] Setting up http.log rotating 10 files of 10000000 bytes each
2014-07-17 11:21:55+0200 [-] while starting BuildMaster
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\twisted\application\service.py", line 308, in addService
service.privilegedStartService()
File "C:\Python27\lib\site-packages\twisted\application\service.py", line 277, in privilegedStartService
service.privilegedStartService()
File "C:\Python27\lib\site-packages\twisted\application\internet.py", line 358, in privilegedStartService
self._waitingForPort = self.endpoint.listen(self.factory)
File "C:\Python27\lib\site-packages\twisted\internet\endpoints.py", line 461, in listen
interface=self._interface)
--- <exception caught here> ---
File "C:\Python27\lib\site-packages\twisted\internet\defer.py", line 108, in execute
result = callable(*args, **kw)
File "C:\Python27\lib\site-packages\twisted\internet\posixbase.py", line 482, in listenTCP
p.startListening()
File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 998, in startListening
self.factory.doStart()
File "C:\Python27\lib\site-packages\twisted\internet\protocol.py", line 72, in doStart
self.startFactory()
File "C:\Python27\lib\site-packages\twisted\web\http.py", line 1844, in startFactory
self.logFile = self._openLogFile(self.logPath)
File "C:\Python27\lib\site-packages\buildbot-0.8.8-py2.7.egg\buildbot\status\web\baseweb.py", line 477, in _openLogFile
return LogFile.fromFullPath(path, rotateLength=rotateLength, maxRotatedFiles=maxRotatedFiles)
File "C:\Python27\lib\site-packages\twisted\python\logfile.py", line 48, in fromFullPath
os.path.dirname(logPath), *args, **kwargs)
File "C:\Python27\lib\site-packages\twisted\python\logfile.py", line 161, in __init__
BaseLogFile.__init__(self, name, directory, defaultMode)
File "C:\Python27\lib\site-packages\twisted\python\logfile.py", line 40, in __init__
self._openFile()
File "C:\Python27\lib\site-packages\twisted\python\logfile.py", line 166, in _openFile
BaseLogFile._openFile(self)
File "C:\Python27\lib\site-packages\twisted\python\logfile.py", line 64, in _openFile
self._file = file(self.path, "r+", 1)
exceptions.IOError: [Errno 22] invalid mode ('r+') or filename: 'E:\\master_dir\\http.log'
我发现我的 http.log 已达到 4GB 的大小,尽管它应该在 10MB 后旋转。为什么 buildbot 在 10MB 后无法旋转 http.log?为什么我收到错误Invalid mode (r+)?是否有构建配置参数来设置http.log 的旋转大小?
删除文件至少解决了启动 buildmaster 的问题,但我仍然不知道为什么我一开始就收到此错误。
我正在运行 buildbot 版本 0.8.8 谢谢。
编辑
根据djmitche 的要求,我尝试使用twisted 日志记录模块。无论斜线的顺序如何,它都可以正常记录。
######## TWISTED ##########
from twisted.python.logfile import LogFile
LOG_FILENAME_TWISTED = r'C:\wp\log_rotate_twisted.log'
lf = LogFile.fromFullPath(LOG_FILENAME_TWISTED, rotateLength=20)
# Log some messages
for i in range(20):
lf.write('i = %d' % i)
【问题讨论】:
-
可能你应该写信给 buildbot 邮件列表,这里没有太多支持
-
是的,没错!无论如何,谢谢。
-
Twisted 示例与 Buildbot 所做的不同 - Buildbot 使用
LogFile.fromFullPath。尝试使您的示例更接近 Buildbot 的功能(请参阅 baseweb.py)。logging示例无关紧要,因此您可以将其关闭。 -
@djmitche 已更新。即使
LogFile.fromFullPath的行为相同,无论斜杠的顺序如何,都能正确记录。 -
那我没主意了。如果给 Twisted 相同的输入在两个不同的应用程序中产生不同的结果,那么有一些隐藏变量在这个线程中是不可见的。弄清楚那是什么,你就会得到答案。