From c32592fd1c7cedd2337054ec4aa3f899ca6183c6 Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Thu, 10 Jul 2014 16:27:29 -0500 Subject: [PATCH] Omaha #3363 fixed ini lookup precedence and improved loggin in cave.sh Change-Id: Ib710d0720a36791d00018e3a4905d27b0b435298 Former-commit-id: 871a8655c8ee93efbda7bde62b643672830596ef [formerly e89daec94625b33f20fc6a9106a63202f4bc7075] Former-commit-id: 0113e109d3d1def5ab4a713cbb360f2aedc6aebe --- cave/build/static/linux/cave/cave.sh | 8 ++- cave/build/static/linux/cave/caveUtil.sh | 67 +++++++++++++----------- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/cave/build/static/linux/cave/cave.sh b/cave/build/static/linux/cave/cave.sh index b43015df8a..3a7607d7ee 100644 --- a/cave/build/static/linux/cave/cave.sh +++ b/cave/build/static/linux/cave/cave.sh @@ -30,6 +30,7 @@ # around this script. # 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 # # @@ -240,10 +241,13 @@ 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} + if [[ "${redirect}" == "true" ]] ; then - exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" > ${LOGFILE} 2>&1 + exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" >> ${LOGFILE} 2>&1 else - exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" 2>&1 | tee ${LOGFILE} + exec ${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES} "${USER_ARGS[@]}" 2>&1 | tee -a ${LOGFILE} fi ) & diff --git a/cave/build/static/linux/cave/caveUtil.sh b/cave/build/static/linux/cave/caveUtil.sh index bc60e1e04e..ae29e90153 100644 --- a/cave/build/static/linux/cave/caveUtil.sh +++ b/cave/build/static/linux/cave/caveUtil.sh @@ -34,6 +34,7 @@ # Mar 13 2014 #15348 kjohnson added function to remove logs # Jun 20, 2014 #3245 bclement forEachRunningCave now accounts for child processes # Jul 02, 2014 #3245 bclement account for memory override in vm arguments +# Jul 10, 2014 #3363 bclement fixed precedence order for ini file lookup source /awips2/cave/iniLookup.sh @@ -50,40 +51,46 @@ BYTES_IN_KB=1024 BYTES_IN_MB=1048576 BYTES_IN_GB=1073741824 +# Looks up ini file first by component/perspective +# then by SITE_TYPE before falling back to cave.ini. +# Sets ini file cave argument string in $CAVE_INI_ARG. +# Returns 0 if component/perspective found in args, else 1. function lookupINI() { - # Arguments: - # - if [ "${1}" == "" ]; then - return 1 + # only check for component/perspective if arguments aren't empty + if [[ "${1}" != "" ]]; then + position=1 + for arg in $@; do + if [ "${arg}" == "-component" ] || + [ "${arg}" == "-perspective" ]; then + # Get The Next Argument. + position=$(( $position + 1 )) + nextArg=${!position} + + retrieveAssociatedINI ${arg} "${nextArg}" + RC=$? + if [ ${RC} -eq 0 ]; then + export CAVE_INI_ARG="--launcher.ini /awips2/cave/${ASSOCIATED_INI}" + return 0 + fi + fi + position=$(( $position + 1 )) + done fi - position=1 - for arg in $@; do - if [ "${arg}" == "-component" ] || - [ "${arg}" == "-perspective" ]; then - # Get The Next Argument. - position=$(( $position + 1 )) - nextArg=${!position} - - retrieveAssociatedINI ${arg} "${nextArg}" - RC=$? - if [ ${RC} -eq 0 ]; then - export CAVE_INI_ARG="--launcher.ini /awips2/cave/${ASSOCIATED_INI}" - else - siteTypeIni="/awips2/cave/${SITE_TYPE}.ini" - if [[ -e ${siteTypeIni} ]] - then - export CAVE_INI_ARG="--launcher.ini ${siteTypeIni}" - else - export CAVE_INI_ARG="--launcher.ini /awips2/cave/cave.ini" - fi - fi - return 0 - fi - position=$(( $position + 1 )) - done - + # if ini wasn't found through component or perspective + if [[ -z $CAVE_INI_ARG ]] + then + # attempt to fall back to site type specific ini + siteTypeIni="/awips2/cave/${SITE_TYPE}.ini" + if [[ -e ${siteTypeIni} ]] + then + export CAVE_INI_ARG="--launcher.ini ${siteTypeIni}" + else + # cave.ini if all else fails + export CAVE_INI_ARG="--launcher.ini /awips2/cave/cave.ini" + fi + fi return 1 }