diff --git a/master/buildbot/scripts/runner.py b/master/buildbot/scripts/runner.py index 12ff17e691d..2f18111a501 100644 --- a/master/buildbot/scripts/runner.py +++ b/master/buildbot/scripts/runner.py @@ -143,6 +143,7 @@ class RestartOptions(base.BasedirMixin, base.SubcommandOptions): subcommandFunction = "buildbot.scripts.restart.restart" optFlags = [ ['quiet', 'q', "Don't display startup log messages"], + ['nodaemon', None, "Don't daemonize (stay in foreground)"], ] def getSynopsis(self): return "Usage: buildbot restart []" @@ -152,6 +153,7 @@ class StartOptions(base.BasedirMixin, base.SubcommandOptions): subcommandFunction = "buildbot.scripts.start.start" optFlags = [ ['quiet', 'q', "Don't display startup log messages"], + ['nodaemon', None, "Don't daemonize (stay in foreground)"], ] def getSynopsis(self): return "Usage: buildbot start []" diff --git a/master/buildbot/scripts/start.py b/master/buildbot/scripts/start.py index 6027885a95a..4df586567b3 100644 --- a/master/buildbot/scripts/start.py +++ b/master/buildbot/scripts/start.py @@ -71,6 +71,8 @@ def launch(config): "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac"] + if config['nodaemon']: + argv.extend(['--nodaemon']) sys.argv = argv # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use diff --git a/master/buildbot/test/unit/test_scripts_runner.py b/master/buildbot/test/unit/test_scripts_runner.py index 2fe41cf72db..24ab9f32f5f 100644 --- a/master/buildbot/test/unit/test_scripts_runner.py +++ b/master/buildbot/test/unit/test_scripts_runner.py @@ -230,11 +230,21 @@ class TestResetartOptions(BaseTestSimpleOptions, unittest.TestCase): commandName = 'restart' optionsClass = runner.RestartOptions + def test_nodaemon(self): + opts = self.parse('--nodaemon') + exp = dict(nodaemon=True) + self.assertOptions(opts, exp) + class TestStartOptions(BaseTestSimpleOptions, unittest.TestCase): commandName = 'start' optionsClass = runner.StartOptions + def test_nodaemon(self): + opts = self.parse('--nodaemon') + exp = dict(nodaemon=True) + self.assertOptions(opts, exp) + class TestReconfigOptions(BaseTestSimpleOptions, unittest.TestCase): commandName = 'reconfig' diff --git a/master/docs/manual/cmdline.rst b/master/docs/manual/cmdline.rst index e2422a608d8..0a58262a19e 100644 --- a/master/docs/manual/cmdline.rst +++ b/master/docs/manual/cmdline.rst @@ -85,6 +85,10 @@ buildmaster administrators: directory. The daemon is launched in the background, with events logged to a file named :file:`twistd.log`. +--nodaemon + Don't daemonize. The process will start in the foreground. + It will only return to the command-line when it is stopped. + ``stop`` This terminates the daemon (either buildmaster or buildslave) running @@ -902,6 +906,10 @@ to a file named :file:`twistd.log`. :: buildbot start BASEDIR +--nodaemon + Don't daemonize. The process will start in the foreground. + It will only return to the command-line when it is stopped. + .. bb:cmdline:: stop (buildslave) stop diff --git a/slave/buildslave/scripts/runner.py b/slave/buildslave/scripts/runner.py index 5b2691c1365..94d551ca419 100644 --- a/slave/buildslave/scripts/runner.py +++ b/slave/buildslave/scripts/runner.py @@ -269,6 +269,7 @@ def postOptions(self): class StartOptions(MakerBase): optFlags = [ ['quiet', 'q', "Don't display startup log messages"], + ['nodaemon', None, "Don't daemonize (stay in foreground)"], ] def getSynopsis(self): return "Usage: buildslave start []" @@ -280,6 +281,7 @@ def getSynopsis(self): class RestartOptions(MakerBase): optFlags = [ ['quiet', 'q', "Don't display startup log messages"], + ['nodaemon', None, "Don't daemonize (stay in foreground)"], ] def getSynopsis(self): return "Usage: buildslave restart []" diff --git a/slave/buildslave/scripts/startup.py b/slave/buildslave/scripts/startup.py index bb2a400e3aa..3abcc1d06ce 100644 --- a/slave/buildslave/scripts/startup.py +++ b/slave/buildslave/scripts/startup.py @@ -109,6 +109,8 @@ def launch(config): "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac"] + if config['nodaemon']: + argv.extend(['--nodaemon']) sys.argv = argv # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use