Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/boothd.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ The configuration name also determines the name of the PID file - for the defaul
Report version information.

*-S*::
'systemd' mode: don't fork. This is like '-D' but without the debug output.
'systemd' mode: don't fork.
Disables daemonizing, the process will remain in the foreground.

*-D*::
Debug output/don't daemonize.
Increases the debug output level; booth daemon remains
in the foreground.
Increases the debug output level.

*-l* 'lockfile'::
Use another lock file. By default, the lock file name is
Expand Down
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,12 +1116,15 @@ static int read_arguments(int argc, char **argv)
strcat(cp, BOOTH_DEFAULT_CONF_EXT);
}
break;

case 'D':
debug_level++;
enable_stderr = 1;

Choose a reason for hiding this comment

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

enable stderr should go below to the 'S' option.

Copy link
Author

Choose a reason for hiding this comment

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

well spotted, thanks

/* Fall through */
break;

case 'S':
daemonize = 0;
enable_stderr = 1;
break;

case 'l':
Expand Down
3 changes: 3 additions & 0 deletions test/boothrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def set_lock_file(self, lock_file):
def set_debug(self):
self.args += [ '-D' ]

def set_foreground(self):
self.args += [ '-S' ]

def all_args(self):
return [ self.boothd_path ] + self.args + self.final_args

Expand Down
15 changes: 10 additions & 5 deletions test/serverenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ServerTestEnvironment(BoothTestEnvironment):

def run_booth(self, expected_exitcode, expected_daemon,
config_text=None, config_file=None, lock_file=True,
args=[], debug=False):
args=[], debug=False, foreground=False):
'''
Runs boothd. Defaults to using a temporary lock file and the
standard config file path. There are four possible types of
Expand All @@ -42,7 +42,7 @@ def run_booth(self, expected_exitcode, expected_daemon,
- boothd exits non-zero without launching a daemon (setup phase failed,
e.g. due to invalid configuration file)
- boothd exits zero after launching a daemon (successful operation)
- boothd does not exit (running in foreground / debug mode)
- boothd does not exit (running in foreground mode)
- boothd does not exit (setup phase hangs, e.g. while attempting
to connect to peer during ticket_catchup())

Expand All @@ -61,13 +61,15 @@ def run_booth(self, expected_exitcode, expected_daemon,
an integer, or False if booth is not expected to terminate
within the timeout
expected_daemon
True iff a daemon is expected to be launched (this includes
running the server in debug / foreground mode via -D; even
though in this case the server's not technically not a daemon,
True iff a daemon is expected to be launched (this means
running the server in foreground mode via -S;
even though in this case the server's not technically not a daemon,
we still want to treat it like one by checking the lockfile
before and after we kill it)
debug
True means pass the -D parameter
foreground
True means pass the -S parameter

Returns a (pid, return_code, stdout, stderr, runner) tuple,
where return_code/stdout/stderr are None iff pid is still running.
Expand Down Expand Up @@ -97,6 +99,9 @@ def run_booth(self, expected_exitcode, expected_daemon,
if debug:
runner.set_debug()

if foreground:
runner.set_foreground()

runner.show_args()
(pid, return_code, stdout, stderr) = runner.run()
self.check_return_code(pid, return_code, expected_exitcode)
Expand Down
10 changes: 10 additions & 0 deletions test/servertests.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def test_missing_quotes(self):
def test_debug_mode(self):
(pid, ret, stdout, stderr, runner) = \
self.run_booth(config_text=self.working_config, debug=True,
expected_exitcode=0, expected_daemon=True)

def test_foreground_mode(self):
(pid, ret, stdout, stderr, runner) = \
self.run_booth(config_text=self.working_config, foreground=True,
expected_exitcode=None, expected_daemon=True)

def test_debug_and_foreground_mode(self):
(pid, ret, stdout, stderr, runner) = \
self.run_booth(config_text=self.working_config, debug=True, foreground=True,
expected_exitcode=None, expected_daemon=True)

def test_missing_transport(self):
Expand Down