From 325a15e08fbfe2a3cc9ca4ecdf11f94b73ae686a Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Fri, 10 Oct 2014 14:08:14 -0500 Subject: [PATCH] Omaha #3675 cave.sh changes to ensure logfile pids match actual cave pid Change-Id: Ibabf5e3f053c8796b70bb95de2459374891f7e59 Former-commit-id: 3eada560b7e4fcb52d0242d685f778503152b489 [formerly b24faf99cdc79308aea37996052f95673bf789b1 [formerly 12b8010ec08ec512a79d90b5ae3b3403acfa1c8c]] Former-commit-id: b24faf99cdc79308aea37996052f95673bf789b1 Former-commit-id: 5ae522c32a88a200251d4881408f1f9c0cc99be6 --- cave/build/static/linux/cave/cave.sh | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cave/build/static/linux/cave/cave.sh b/cave/build/static/linux/cave/cave.sh index 3a7607d7ee..7bb4f35ad9 100644 --- a/cave/build/static/linux/cave/cave.sh +++ b/cave/build/static/linux/cave/cave.sh @@ -31,6 +31,7 @@ # Jan 24, 2014 #2739 bsteffen Log exit status # Jan 30, 2014 #2593 bclement warns based on memory usage, fixed for INI files with spaces # Jul 10, 2014 #3363 bclement logs command used to launch application to console logs +# Oct 10, 2014 #3675 njensen Logback now does console logging to ensure correct pid # # @@ -210,13 +211,14 @@ curTime=`date +%Y%m%d_%H%M%S` ( export pid=`/bin/bash -c 'echo $PPID'` - LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log" - export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_alertviz.log" - export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_perf.log" + LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_startup-shutdown.log" + export LOGFILE_CAVE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_logs.log" + export LOGFILE_CONSOLE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_console.log" + export LOGFILE_PERFORMANCE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_perf.log" # can we write to log directory if [ -w ${LOGDIR} ]; then - touch ${LOGFILE} + touch ${LOGFILE_STARTUP_SHUTDOWN} fi # remove "-noredirect" flag from command-line if set so it doesn't confuse any @@ -241,18 +243,23 @@ curTime=`date +%Y%m%d_%H%M%S` nohup ${CAVE_INSTALL}/monitorThreads.sh $pid >> /dev/null 2>&1 & fi - echo "Launching cave application using the following command: " >> ${LOGFILE} - echo "${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} ${USER_ARGS[@]}" >> ${LOGFILE} + echo "Launching cave application using the following command: " >> ${LOGFILE_STARTUP_SHUTDOWN} + echo "${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} ${USER_ARGS[@]}" >> ${LOGFILE_STARTUP_SHUTDOWN} + # TODO would be cool if we spawned another process to figure out the pid of + # the actual cave java process and logged that to the startup file to make it + # easier to correlate a startup log to the other cave logs - if [[ "${redirect}" == "true" ]] ; then - exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" >> ${LOGFILE} 2>&1 + if [[ "${redirect}" == "true" ]] ; then + # send output to /dev/null because the logback CaveConsoleAppender will capture that output + exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" >> /dev/null 2>&1 else - exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" 2>&1 | tee -a ${LOGFILE} + # allow output to print to the console/terminal that launched CAVE + exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" 2>&1 fi ) & pid=$! -LOGFILE="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_console.log" -logExitStatus $pid $LOGFILE +LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_startup-shutdown.log" +logExitStatus $pid $LOGFILE_STARTUP_SHUTDOWN