最近,当我尝试重新启动我的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)
答案 0 :(得分:0)
这可能是Twisted Python的一个问题(我建议添加相应的标签)。
您是否可以通过修补_openLogFile中的C:\Python27\lib\site-packages\buildbot-0.8.8-py2.7.egg\buildbot\status\web\baseweb.py
打印rotateLength
来验证是否正确设置了日志轮换参数?重新启动主服务器时,打印输出将显示在twistd.log
中。