Merge "Omaha #3675 cave.sh changes to ensure logfile pids match actual cave pid" into omaha_14.4.1

Former-commit-id: eb68a84c26 [formerly ef5fcfe852] [formerly d2909b6e08] [formerly eb68a84c26 [formerly ef5fcfe852] [formerly d2909b6e08] [formerly 360114be70 [formerly d2909b6e08 [formerly a7b644d5e831bc38f0442efc16f681fd5ff317d7]]]]
Former-commit-id: 360114be70
Former-commit-id: c96334f119 [formerly 7d16235944] [formerly ec399aa3cec1a79c1ac60a6c14f35c55bc21a53e [formerly f692cbf631]]
Former-commit-id: 294e5f864ee370d7611bab2b6ab2694474a5048d [formerly d5908e242a]
Former-commit-id: ee07857e4f
This commit is contained in:
Richard Peter 2014-10-13 12:37:28 -05:00 committed by Gerrit Code Review
commit 9dd2d6522e

View file

@ -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