Omaha #3675 startup shutdown log name includes child pid
fixed capture Change-Id: Ifdd83f3f420bc50fd6d49a1ddaa2f83b20ab97f7 Former-commit-id:78c2aa3650
[formerly3a12ab9bdf
] [formerly6d6d3d26e6
[formerly 84a91d7b11790d4a37abc9b0a5c2d64952321b52]] Former-commit-id:6d6d3d26e6
Former-commit-id:470a695a1a
This commit is contained in:
parent
7d16235944
commit
d2042e3485
3 changed files with 34 additions and 7 deletions
|
@ -32,6 +32,7 @@
|
|||
# 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
|
||||
# Oct 13, 2014 #3675 bclement startup shutdown log includes both launching pid and placeholder
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -211,7 +212,9 @@ curTime=`date +%Y%m%d_%H%M%S`
|
|||
(
|
||||
export pid=`/bin/bash -c 'echo $PPID'`
|
||||
|
||||
LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_startup-shutdown.log"
|
||||
# we include the PID of the launching process along with
|
||||
# a %PID% placeholder to be replaced with the "real" PID
|
||||
LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${pid}_${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"
|
||||
|
@ -245,9 +248,6 @@ curTime=`date +%Y%m%d_%H%M%S`
|
|||
|
||||
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
|
||||
# send output to /dev/null because the logback CaveConsoleAppender will capture that output
|
||||
|
@ -259,7 +259,7 @@ curTime=`date +%Y%m%d_%H%M%S`
|
|||
) &
|
||||
|
||||
pid=$!
|
||||
LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_${pid}_startup-shutdown.log"
|
||||
LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${pid}_${curTime}_pid_%PID%_startup-shutdown.log"
|
||||
logExitStatus $pid $LOGFILE_STARTUP_SHUTDOWN
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
# Jul 02, 2014 #3245 bclement account for memory override in vm arguments
|
||||
# Jul 10, 2014 #3363 bclement fixed precedence order for ini file lookup
|
||||
# Jul 11, 2014 #3371 bclement added killSpawn()
|
||||
# Oct 13, 2014 #3675 bclement logExitStatus() waits for child to start and renames log with child PID
|
||||
|
||||
|
||||
source /awips2/cave/iniLookup.sh
|
||||
|
@ -330,6 +331,14 @@ function logExitStatus()
|
|||
logFile=$2
|
||||
|
||||
trap 'killSpawn $pid' SIGHUP SIGINT SIGQUIT SIGTERM
|
||||
|
||||
childPid=$(waitForChildToStart $pid)
|
||||
if [[ -n $childPid ]]
|
||||
then
|
||||
newFileName=${logFile/\%PID\%/$childPid}
|
||||
mv $logFile $newFileName
|
||||
logFile=$newFileName
|
||||
fi
|
||||
wait $pid
|
||||
exitCode=$?
|
||||
curTime=`date --rfc-3339=seconds`
|
||||
|
@ -348,6 +357,24 @@ function logExitStatus()
|
|||
fi
|
||||
}
|
||||
|
||||
# takes in a PID
|
||||
# waits for PID to spawn child
|
||||
# outputs the PID of the child or nothing if PID exits first
|
||||
function waitForChildToStart()
|
||||
{
|
||||
pid=$1
|
||||
# check if PID is still running
|
||||
while ps -p $pid > /dev/null
|
||||
do
|
||||
sleep 1s
|
||||
if child=$(pgrep -P $pid)
|
||||
then
|
||||
echo $child
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#Delete old CAVE logs DR 15348
|
||||
function deleteOldCaveLogs()
|
||||
{
|
||||
|
|
|
@ -718,8 +718,8 @@ if [ "${GRAB_CAVE_AND_ALERTVIZ_LOGS}" == "y" ]; then
|
|||
echo "${t1}: Capturing cave logs" >> $processFile
|
||||
mkdir -p ${dataPath}/consoleLogs
|
||||
if [ ! -z ${cavePid} ]; then
|
||||
# logs have cave executable pid in the name, not worker pid
|
||||
find $dir -type f -name "*$(determineCaveProcess ${cavePid})*" -exec cp {} ${dataPath}/consoleLogs \;
|
||||
# logs have cave executable pid or worker pid in the name (-o means OR)
|
||||
find $dir -type f -name "*$(determineCaveProcess ${cavePid})*" -o -name "*${cavePid}*" -exec cp {} ${dataPath}/consoleLogs \;
|
||||
else
|
||||
find $dir -type f -mmin -120 -exec cp {} ${dataPath}/consoleLogs \;
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue