Skip to content

Commit

Permalink
Merge branch 'pull554'
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Feb 1, 2013
2 parents 74f6ac8 + b5572aa commit 8254a14
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions master/buildbot/master.py
Expand Up @@ -195,6 +195,11 @@ def sighup(*args):
eventually(self.reconfig)
signal.signal(signal.SIGHUP, sighup)

if hasattr(signal, "SIGUSR1"):
def sigusr1(*args):
_reactor.callLater(0, self.botmaster.cleanShutdown)
signal.signal(signal.SIGUSR1, sigusr1)

# call the parent method
yield defer.maybeDeferred(lambda :
service.MultiService.startService(self))
Expand Down
1 change: 1 addition & 0 deletions master/buildbot/scripts/runner.py
Expand Up @@ -134,6 +134,7 @@ class StopOptions(base.BasedirMixin, base.SubcommandOptions):
subcommandFunction = "buildbot.scripts.stop.stop"
optFlags = [
["quiet", "q", "Do not emit the commands being run"],
["clean", "c", "Clean shutdown master"],
]
def getSynopsis(self):
return "Usage: buildbot stop [<basedir>]"
Expand Down
3 changes: 3 additions & 0 deletions master/buildbot/scripts/stop.py
Expand Up @@ -25,6 +25,9 @@ def stop(config, signame="TERM", wait=False):
basedir = config['basedir']
quiet = config['quiet']

if config['clean']:
signame = 'USR1'

if not base.isBuildmasterDir(config['basedir']):
print "not a buildmaster directory"
return 1
Expand Down
9 changes: 8 additions & 1 deletion master/buildbot/test/unit/test_scripts_stop.py
Expand Up @@ -23,7 +23,7 @@
from buildbot.test.util import dirs, misc, compat

def mkconfig(**kwargs):
config = dict(quiet=False, basedir=os.path.abspath('basedir'))
config = dict(quiet=False, clean=False, basedir=os.path.abspath('basedir'))
config.update(kwargs)
return config

Expand Down Expand Up @@ -117,3 +117,10 @@ def test_stop_slow_death_wait_timeout(self):
wait=True)
self.assertInStdout('never saw process')
self.assertEqual(rv, 1)

@compat.skipUnlessPlatformIs('posix')
def test_stop_clean(self):
rv = self.do_test_stop(mkconfig(clean=True), [
(signal.SIGUSR1, None), ], wait=False)
self.assertInStdout('sent SIGUSR1 to process')
self.assertEqual(rv, 0)
1 change: 1 addition & 0 deletions master/docs/manual/cmdline.rst
Expand Up @@ -114,6 +114,7 @@ stop
buildbot stop {BASEDIR}
This terminates the daemon (either buildmaster or buildslave) running in the given directory.
The :option:`--clean` option shuts down the buildmaster cleanly.

.. bb:cmdline:: sighup
Expand Down

0 comments on commit 8254a14

Please sign in to comment.