Skip to content

Commit

Permalink
scripts: allow startup timeout to be specified
Browse files Browse the repository at this point in the history
At the buildbot startup, we had waited 10sec for the process to come up.
However, there has been cases where this period hasn't been enough. So,
let the caller specify the allowed timeout for the server to start,
eg:
    buildbot start -t 20.0
  • Loading branch information
xrg committed Sep 6, 2011
1 parent 09ef93d commit 95d728c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions master/buildbot/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ class StartOptions(MakerBase):
optFlags = [
['quiet', 'q', "Don't display startup log messages"],
]
optParameters = [
['timeout', 't', None, "Wait for server to startup that many seconds"]
]
def getSynopsis(self):
return "Usage: buildbot start [<basedir>]"

Expand All @@ -714,6 +717,9 @@ class RestartOptions(MakerBase):
optFlags = [
['quiet', 'q', "Don't display startup log messages"],
]
optParameters = [
['timeout', 't', None, "Wait for server to startup that many seconds"]
]
def getSynopsis(self):
return "Usage: buildbot restart [<basedir>]"

Expand Down
18 changes: 12 additions & 6 deletions master/buildbot/scripts/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
import os, sys, time

class Follower:
def follow(self):
def follow(self, timeout=None):
from twisted.internet import reactor
from buildbot.scripts.logwatcher import LogWatcher
self.rc = 0
print "Following twistd.log until startup finished.."
lw = LogWatcher("twistd.log")
if timeout is not None:
lw.TIMEOUT_DELAY = float(timeout)
self.timeout = lw.TIMEOUT_DELAY
d = lw.start()
d.addCallbacks(self._success, self._failure)
reactor.run()
Expand All @@ -40,13 +43,13 @@ def _failure(self, why):
ReconfigError, BuildslaveTimeoutError, BuildSlaveDetectedError
if why.check(BuildmasterTimeoutError):
print """
The buildmaster took more than 10 seconds to start, so we were unable to
The buildmaster took more than %d seconds to start, so we were unable to
confirm that it started correctly. Please 'tail twistd.log' and look for a
line that says 'configuration update complete' to verify correct startup.
"""
""" % int(self.timeout)
elif why.check(BuildslaveTimeoutError):
print """
The buildslave took more than 10 seconds to start and/or connect to the
The buildslave took more than %d seconds to start and/or connect to the
buildmaster, so we were unable to confirm that it started and connected
correctly. Please 'tail twistd.log' and look for a line that says 'message
from master: attached' to verify correct startup. If you see a bunch of
Expand All @@ -56,7 +59,7 @@ def _failure(self, why):
'Failure: twisted.cred.error.UnauthorizedLogin'
then your buildslave might be using the wrong botname or password. Please
correct these problems and then restart the buildslave.
"""
""" % int(self.timeout)
elif why.check(ReconfigError):
print """
The buildmaster appears to have encountered an error in the master.cfg config
Expand Down Expand Up @@ -97,7 +100,10 @@ def start(config):
# logfile
if os.fork():
# this is the parent
rc = Follower().follow()
timeout = None
if 'timeout' in config and config['timeout']:
timeout = float(config['timeout'])
rc = Follower().follow(timeout=timeout)
sys.exit(rc)
# this is the child: give the logfile-watching parent a chance to start
# watching it before we start the daemon
Expand Down

2 comments on commit 95d728c

@benallard
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should fill a pull request for buildbot/buildbot for the buildbot team to look at it.

@djmitche
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do! Note that this will need some work to merge against master -- but nothing too difficult, I think.

Please sign in to comment.