Commit 5727032b authored by Mike Hibler's avatar Mike Hibler

Allow debug and daemonize at the same time with -D flag.

And add DEBUG setting in rc.d startup scripts. This is something we had been
doing on subbosses with a hack, but I kept overwriting the hack!
parent 253f18e2
/* /*
* Copyright (c) 2010-2012 University of Utah and the Flux Group. * Copyright (c) 2010-2013 University of Utah and the Flux Group.
* *
* {{{EMULAB-LICENSE * {{{EMULAB-LICENSE
* *
...@@ -114,7 +114,13 @@ main(int argc, char **argv) ...@@ -114,7 +114,13 @@ main(int argc, char **argv)
myuid = geteuid(); myuid = geteuid();
mygid = getegid(); mygid = getegid();
MasterServerLogInit(); if (daemonize && debug) {
int odebug = debug;
debug = 0;
MasterServerLogInit();
debug = odebug;
} else
MasterServerLogInit();
log("mfrisbeed daemon starting as %d/%d, methods=%s (debug level %d)", log("mfrisbeed daemon starting as %d/%d, methods=%s (debug level %d)",
myuid, mygid, GetMSMethods(onlymethods), debug); myuid, mygid, GetMSMethods(onlymethods), debug);
...@@ -1342,7 +1348,7 @@ usage(void) ...@@ -1342,7 +1348,7 @@ usage(void)
fprintf(stderr, " -p <port> port to listen on\n"); fprintf(stderr, " -p <port> port to listen on\n");
fprintf(stderr, "Debug:\n"); fprintf(stderr, "Debug:\n");
fprintf(stderr, " -d debug mode; does not daemonize\n"); fprintf(stderr, " -d debug mode; does not daemonize\n");
fprintf(stderr, " -D dump configuration and exit\n"); fprintf(stderr, " -D force daemonizing even with debug\n");
fprintf(stderr, "Proxying:\n"); fprintf(stderr, "Proxying:\n");
fprintf(stderr, " -S <parent> parent name or IP\n"); fprintf(stderr, " -S <parent> parent name or IP\n");
fprintf(stderr, " -P <pport> parent port to contact\n"); fprintf(stderr, " -P <pport> parent port to contact\n");
...@@ -1356,6 +1362,7 @@ static void ...@@ -1356,6 +1362,7 @@ static void
get_options(int argc, char **argv) get_options(int argc, char **argv)
{ {
int ch; int ch;
int forcedaemonize = 0;
while ((ch = getopt(argc, argv, "AC:O:DI:MRX:x:S:P:p:i:dhQ:")) != -1) while ((ch = getopt(argc, argv, "AC:O:DI:MRX:x:S:P:p:i:dhQ:")) != -1)
switch(ch) { switch(ch) {
...@@ -1413,7 +1420,7 @@ get_options(int argc, char **argv) ...@@ -1413,7 +1420,7 @@ get_options(int argc, char **argv)
debug++; debug++;
break; break;
case 'D': case 'D':
dumpconfig = 1; forcedaemonize = 1;
break; break;
case 'I': case 'I':
{ {
...@@ -1482,6 +1489,9 @@ get_options(int argc, char **argv) ...@@ -1482,6 +1489,9 @@ get_options(int argc, char **argv)
"Error: Must specify a parent (-S) in mirror mode\n"); "Error: Must specify a parent (-S) in mirror mode\n");
usage(); usage();
} }
if (forcedaemonize)
daemonize = 1;
} }
/* /*
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#MCBASEADDR="" #MCBASEADDR=""
MCBASEADDR="239.192.1" MCBASEADDR="239.192.1"
#
# Set to run with debugging enabled.
#
#DEBUG=
DEBUG=yes
# #
# Start up the frisbee master server on a subboss. # Start up the frisbee master server on a subboss.
# There is no sure fire way to dynamically tell if we are a subboss right now. # There is no sure fire way to dynamically tell if we are a subboss right now.
...@@ -65,11 +71,16 @@ esac ...@@ -65,11 +71,16 @@ esac
echo -n " mfrisbeed" echo -n " mfrisbeed"
rm -f /var/run/frisbeed-*.pid rm -f /var/run/frisbeed-*.pid
args="-C null -S @BOSSNODE_IP@ -I /z/image_cache -A -M -R" args="-C null -S @BOSSNODE_IP@ -I /z/image_cache -A -M -R"
if [ -n "$MCBASEADDR" ]; then if [ -n "$MCBASEADDR" ]; then
args="$args -O mcaddr=$MCBASEADDR" args="$args -O mcaddr=$MCBASEADDR"
fi fi
if [ -x @prefix@/sbin/daemon_wrapper ]; then if [ -n "$DEBUG" ]; then
args="-ddD $args"
fi
if [ -z "$DEBUG" -a -x @prefix@/sbin/daemon_wrapper ]; then
@prefix@/sbin/daemon_wrapper -i 30 -l @prefix@/log/mfrisbeed_wrapper.log \ @prefix@/sbin/daemon_wrapper -i 30 -l @prefix@/log/mfrisbeed_wrapper.log \
@prefix@/sbin/mfrisbeed -d $args @prefix@/sbin/mfrisbeed -d $args
else else
......
...@@ -6,7 +6,13 @@ ...@@ -6,7 +6,13 @@
# KEYWORD: shutdown # KEYWORD: shutdown
# #
# Start up the frisbee master server. # Set to run with debugging enabled.
#
#DEBUG=
DEBUG=yes
#
# Start up the frisbee master server on boss.
# We run it under the daemon wrapper if available so that it will get # We run it under the daemon wrapper if available so that it will get
# automatically restarted. # automatically restarted.
# #
...@@ -71,19 +77,19 @@ rm -f /var/run/frisbeed-*.pid ...@@ -71,19 +77,19 @@ rm -f /var/run/frisbeed-*.pid
args="-C emulab -i @BOSSNODE_IP@" args="-C emulab -i @BOSSNODE_IP@"
# to allow broadcast, uncomment the following line # to allow broadcast, uncomment the following line
#args="$args -x ucast,mcast,bcast" #args="$args -x ucast,mcast,bcast"
# if an inner elab, use outer boss as our parent # if an inner elab, use outer boss as our parent
if [ -n "@OUTERBOSS_NODENAME@" ]; then if [ -n "@OUTERBOSS_NODENAME@" ]; then
args="$args -S @OUTERBOSS_NODENAME@" args="$args -S @OUTERBOSS_NODENAME@"
fi fi
# see if we need to be an IGMP querier # see if we need to be an IGMP querier
if [ "@NEEDMCQUERIER@" = "1" ]; then if [ "@NEEDMCQUERIER@" = "1" ]; then
args="$args -Q 30" args="$args -Q 30"
fi fi
if [ -n "$DEBUG" ]; then
args="-ddD $args"
fi
# XXX I am actually NOT going to run it under the wrapper for now if [ -z "$DEBUG" -a -x @prefix@/sbin/daemon_wrapper ]; then
if false && [ -x @prefix@/sbin/daemon_wrapper ]; then
@prefix@/sbin/daemon_wrapper -i 30 -l @prefix@/log/mfrisbeed_wrapper.log \ @prefix@/sbin/daemon_wrapper -i 30 -l @prefix@/log/mfrisbeed_wrapper.log \
@prefix@/sbin/mfrisbeed -d $args @prefix@/sbin/mfrisbeed -d $args
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment