Skip to content
Browse files

Add separate http-log with fixed rotation parameters (fixes #684)

  • Loading branch information...
1 parent d4588d2 commit 64ef8f15ebe141e4c48201eb860b92843e5a72d1 @marcusl marcusl committed Apr 5, 2010
Showing with 33 additions and 20 deletions.
  1. +33 −20 buildbot/status/web/baseweb.py
View
53 buildbot/status/web/baseweb.py
@@ -265,23 +265,14 @@ def __init__(self, http_port=None, distrib_port=None, allowForce=None,
self.orderConsoleByTime = order_console_by_time
- # If we were given a site object, go ahead and use it.
- if site:
- self.site = site
- else:
- # this will be replaced once we've been attached to a parent (and
- # thus have a basedir and can reference BASEDIR)
- root = static.Data("placeholder", "text/plain")
- self.site = server.Site(root)
- self.childrenToBeAdded = {}
+ # If we were given a site object, go ahead and use it. (if not, we add one later)
+ self.site = site
+ # create the web site page structure
+ self.childrenToBeAdded = {}
self.setupUsualPages(numbuilds=numbuilds, num_events=num_events,
num_events_max=num_events_max)
- # the following items are accessed by HtmlResource when it renders
- # each page.
- self.site.buildbot_service = self
-
# Set up the jinja templating engine.
self.templates = createJinjaEnv(revlink, changecommentlink,
repositories, projects)
@@ -290,13 +281,6 @@ def __init__(self, http_port=None, distrib_port=None, allowForce=None,
# down. See ticket #102 for more details.
self.channels = weakref.WeakKeyDictionary()
- if self.http_port is not None:
- s = strports.service(self.http_port, self.site)
- s.setServiceParent(self)
- if self.distrib_port is not None:
- f = pb.PBServerFactory(distrib.ResourcePublisher(self.site))
- s = strports.service(self.distrib_port, f)
- s.setServiceParent(self)
def setupUsualPages(self, numbuilds, num_events, num_events_max):
#self.putChild("", IndexOrWaterfallRedirection())
@@ -337,6 +321,35 @@ def setServiceParent(self, parent):
# be able to get reasonable results.
self.master = parent
+ if not self.site:
+ class MySite(server.Site):
+ def _openLogFile(self, path):
+ try:
+ # TODO: Use same log rotate parameters as twistd.log (from buildbot.tac)
+ from twisted.python.logfile import LogFile
+ return LogFile.fromFullPath(path, rotateLength=1 * 1000 * 1000, maxRotatedFiles=10)
+ except ImportError, e:
+ log.msg("WebStatus: Unable to set up rotating http.log: %s" % e)
+ return server.Site._openLogFile(self, path)
+
+ # this will be replaced once we've been attached to a parent (and
+ # thus have a basedir and can reference BASEDIR)
+ root = static.Data("placeholder", "text/plain")
+ httplog = os.path.abspath(os.path.join(self.master.basedir, "http.log"))
+ self.site = MySite(root, logPath=httplog)
+
+ # the following items are accessed by HtmlResource when it renders
+ # each page.
+ self.site.buildbot_service = self
+
+ if self.http_port is not None:
+ s = strports.service(self.http_port, self.site)
+ s.setServiceParent(self)
+ if self.distrib_port is not None:
+ f = pb.PBServerFactory(distrib.ResourcePublisher(self.site))
+ s = strports.service(self.distrib_port, f)
+ s.setServiceParent(self)
+
self.setupSite()
def setupSite(self):

0 comments on commit 64ef8f1

Please sign in to comment.
Something went wrong with that request. Please try again.