From 5727032b1cebe06b89dea3555a690cb01cdd1d4e Mon Sep 17 00:00:00 2001 From: Mike Hibler <hibler@cs.utah.edu> Date: Mon, 14 Jan 2013 21:23:40 -0700 Subject: [PATCH] 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! --- clientside/os/frisbee.redux/mserver.c | 18 ++++++++++++++---- rc.d/3.mfrisbeed-subboss.sh.in | 13 ++++++++++++- rc.d/3.mfrisbeed.sh.in | 16 +++++++++++----- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/clientside/os/frisbee.redux/mserver.c b/clientside/os/frisbee.redux/mserver.c index 81ca5690d6..3e1c04f1f0 100644 --- a/clientside/os/frisbee.redux/mserver.c +++ b/clientside/os/frisbee.redux/mserver.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2012 University of Utah and the Flux Group. + * Copyright (c) 2010-2013 University of Utah and the Flux Group. * * {{{EMULAB-LICENSE * @@ -114,7 +114,13 @@ main(int argc, char **argv) myuid = geteuid(); 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)", myuid, mygid, GetMSMethods(onlymethods), debug); @@ -1342,7 +1348,7 @@ usage(void) fprintf(stderr, " -p <port> port to listen on\n"); fprintf(stderr, "Debug:\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, " -S <parent> parent name or IP\n"); fprintf(stderr, " -P <pport> parent port to contact\n"); @@ -1356,6 +1362,7 @@ static void get_options(int argc, char **argv) { int ch; + int forcedaemonize = 0; while ((ch = getopt(argc, argv, "AC:O:DI:MRX:x:S:P:p:i:dhQ:")) != -1) switch(ch) { @@ -1413,7 +1420,7 @@ get_options(int argc, char **argv) debug++; break; case 'D': - dumpconfig = 1; + forcedaemonize = 1; break; case 'I': { @@ -1482,6 +1489,9 @@ get_options(int argc, char **argv) "Error: Must specify a parent (-S) in mirror mode\n"); usage(); } + + if (forcedaemonize) + daemonize = 1; } /* diff --git a/rc.d/3.mfrisbeed-subboss.sh.in b/rc.d/3.mfrisbeed-subboss.sh.in index 32647a6316..f27a61a056 100644 --- a/rc.d/3.mfrisbeed-subboss.sh.in +++ b/rc.d/3.mfrisbeed-subboss.sh.in @@ -13,6 +13,12 @@ #MCBASEADDR="" MCBASEADDR="239.192.1" +# +# Set to run with debugging enabled. +# +#DEBUG= +DEBUG=yes + # # 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. @@ -65,11 +71,16 @@ esac echo -n " mfrisbeed" rm -f /var/run/frisbeed-*.pid + args="-C null -S @BOSSNODE_IP@ -I /z/image_cache -A -M -R" if [ -n "$MCBASEADDR" ]; then args="$args -O mcaddr=$MCBASEADDR" 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/mfrisbeed -d $args else diff --git a/rc.d/3.mfrisbeed.sh.in b/rc.d/3.mfrisbeed.sh.in index b6af6584dd..c4d1712c30 100644 --- a/rc.d/3.mfrisbeed.sh.in +++ b/rc.d/3.mfrisbeed.sh.in @@ -6,7 +6,13 @@ # 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 # automatically restarted. # @@ -71,19 +77,19 @@ rm -f /var/run/frisbeed-*.pid args="-C emulab -i @BOSSNODE_IP@" # to allow broadcast, uncomment the following line #args="$args -x ucast,mcast,bcast" - # if an inner elab, use outer boss as our parent if [ -n "@OUTERBOSS_NODENAME@" ]; then args="$args -S @OUTERBOSS_NODENAME@" fi - # see if we need to be an IGMP querier if [ "@NEEDMCQUERIER@" = "1" ]; then args="$args -Q 30" fi +if [ -n "$DEBUG" ]; then + args="-ddD $args" +fi -# XXX I am actually NOT going to run it under the wrapper for now -if false && [ -x @prefix@/sbin/daemon_wrapper ]; then +if [ -z "$DEBUG" -a -x @prefix@/sbin/daemon_wrapper ]; then @prefix@/sbin/daemon_wrapper -i 30 -l @prefix@/log/mfrisbeed_wrapper.log \ @prefix@/sbin/mfrisbeed -d $args else -- GitLab