added a new command line argument '-n' to prevent Monitorix from daemonizing and force it to run in the foreground

This commit is contained in:
Jordi Sanfeliu 2014-04-08 12:54:32 +02:00
parent fcdd419251
commit 71d905d499
1 changed files with 5 additions and 4 deletions

View File

@ -102,7 +102,7 @@ sub daemonize {
sub usage {
print(STDERR << "EOF");
Usage: monitorix -c configfile [-p pidfile] [-d none | graph[,graph] | all ] [-v]
Usage: monitorix -c configfile [-p pidfile] [-d none | graph[,graph] | all ] [-v] [-n]
EOF
exit(1);
@ -366,7 +366,7 @@ EOF
# Main
# ----------------------------------------------------------------------------
getopts("d:vc:p:", \%options) || usage();
getopts("c:p:d:vn", \%options) || usage();
if($options{v}) {
print("Monitorix version " . VERSION . " (" . RELDATE . ")\n");
@ -412,9 +412,10 @@ $0 = sprintf("%s %s%s%s%s",
$options{c} ? "-c $options{c}" : "",
$options{p} ? " -p $options{p}" : "",
$options{d} ? " -d $options{d}" : "",
$options{v} ? " -v" : "");
$options{v} ? " -v" : "",
$options{n} ? " -n" : "");
daemonize();
daemonize() unless $options{n};
logger("Starting Monitorix version " . VERSION . " (pid $$).");
# save the pidfile