【问题标题】:Buildbot master's http.log errorBuildbot master 的 http.log 错误
【发布时间】: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 相同的输入在两个不同的应用程序中产生不同的结果,那么有一些隐藏变量在这个线程中是不可见的。弄清楚那是什么,你就会得到答案。

标签: twisted buildbot


【解决方案1】:

这可能是 Twisted Python 的一个问题(我建议添加相应的标签)。

您能否验证日志轮换参数是否设置正确,也许通过在_openLogFile 中修补C:\Python27\lib\site-packages\buildbot-0.8.8-py2.7.egg\buildbot\status\web\baseweb.py 以打印rotateLength?重启master时打印输出会出现在twistd.log中。

【讨论】:

  • 是的,也许这是 Twisted 的问题。我按照您的建议进行了尝试,它说 10000000 字节(10MB),与问题中的日志消息相同。我刚刚注意到http.logtwisted.log 都超过了10MB,目前是250+MB
  • 你使用的是什么版本的 Twisted?
  • 我使用的是 13.1.0 版本
  • 那是相当新的东西。所以,也许你在启动时看到的这个异常是相关的。 stackoverflow.com/questions/14015857/… 表明问题在于传递反斜杠路径,而 Python 需要正斜杠(并在 Windows 上自动转换)。尝试将您的 master basedir 设置为 C:/master
  • 我通过使用logging.handlers.RotatingFileHandler 编写一个小程序快速检查,无论我在日志文件名中使用正斜杠还是反斜杠,结果都保持不变——日志文件旋转和创建新文件的两种方式。所以这似乎不是问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多