From ae94ee283a95994f343df91a87deead2d9aa908b Mon Sep 17 00:00:00 2001 From: mjames-upc Date: Mon, 25 Apr 2016 20:35:03 -0500 Subject: [PATCH] remove CAVE memory check; alias cave in /etc/profile.d; reintroduce run.sh to pass thinclient/alertviz components --- cave/build/static/linux/cave/cave.sh | 268 +----------------- cave/build/static/linux/cave/run.sh | 227 +++++++++++++++ .../scripts/profile.d/awips2.csh | 1 + .../scripts/profile.d/awips2.sh | 2 +- 4 files changed, 230 insertions(+), 268 deletions(-) create mode 100644 cave/build/static/linux/cave/run.sh diff --git a/cave/build/static/linux/cave/cave.sh b/cave/build/static/linux/cave/cave.sh index 867dc7cb27..8011b9f977 100644 --- a/cave/build/static/linux/cave/cave.sh +++ b/cave/build/static/linux/cave/cave.sh @@ -1,268 +1,2 @@ #!/bin/bash -# CAVE startup script -# Note: CAVE will not run as 'root' - -# This software was developed and / or modified by Raytheon Company, -# pursuant to Contract DG133W-05-CQ-1067 with the US Government. -# -# U.S. EXPORT CONTROLLED TECHNICAL DATA -# This software product contains export-restricted data whose -# export/transfer/disclosure is restricted by U.S. law. Dissemination -# to non-U.S. persons whether in the United States or abroad requires -# an export license or other authorization. -# -# Contractor Name: Raytheon Company -# Contractor Address: 6825 Pine Street, Suite 340 -# Mail Stop B8 -# Omaha, NE 68106 -# 402.291.0100 -# -# See the AWIPS II Master Rights File ("Master Rights File.pdf") for -# further licensing information. -# -# -# SOFTWARE HISTORY -# Date Ticket# Engineer Description -# ------------ ---------- ----------- -------------------------- -# Dec 05, 2013 #2593 rjpeter Added check for number of running -# cave sessions. -# Dec 05, 2013 #2590 dgilling Modified so gfeclient.sh can be wrapped -# 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 -# 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 -# Jan 28, 2015 #4018 randerso Added a productEditor log file to changes in the GFE product editor -# Jun 17, 2015 #4148 rferrel Logback needs fewer environment variables. -# Jul 23, 2015 ASM#13849 D. Friedman Use a unique Eclipse configuration directory -# Aug 03, 2015 #4694 dlovely Logback will now add user.home to LOGDIR -# - - -user=`/usr/bin/whoami` -if [ ${user} == 'root' ];then - echo "WARNING: CAVE cannot be run as user '${user}'!" - echo " change to another user and run again." - exit 1 -fi - -# Since, we no longer need to worry about re-location ... -CAVE_INSTALL="/awips2/cave" -JAVA_INSTALL="/awips2/java" -PYTHON_INSTALL="/awips2/python" -export AWIPS_INSTALL_DIR="${CAVE_INSTALL}" - -MAX_MEM_PROPORTION="0.85" - -source ${CAVE_INSTALL}/caveUtil.sh -RC=$? -if [ ${RC} -ne 0 ]; then - echo "ERROR: unable to find and/or access ${CAVE_INSTALL}/caveUtil.sh." - exit 1 -fi - -# Run monitorThreads? -runMonitorThreads=false - -# copy the viz shutdown utility if necessary. -copyVizShutdownUtilIfNecessary - -# delete any old disk caches in the background -deleteOldCaveDiskCaches & - -# Enable core dumps -ulimit -c unlimited >> /dev/null 2>&1 - -export LD_LIBRARY_PATH=${JAVA_INSTALL}/lib:${PYTHON_INSTALL}/lib:$LD_LIBRARY_PATH -if [[ -z "$CALLED_EXTEND_LIB_PATH" ]]; then - extendLibraryPath -fi -export PATH=${JAVA_INSTALL}/bin:${PYTHON_INSTALL}/bin:$PATH -export JAVA_HOME="${JAVA_INSTALL}/jre" - -# The user can update this field if they choose to do so. -export HYDRO_APPS_DIR="/awips2/edex/data/share/hydroapps" - -export EDEX_HOME=/awips2/edex -export LOCALIZATION_ROOT=~/caveData/common -export PGSQL_DRIVER_DIR=`ls -1d /awips2/cave/plugins/org.postgres_*` -if [ $? -ne 0 ]; then - echo "FATAL: Unable to locate the PostgreSQL JDBC Driver." - exit 1 -fi -export apps_dir=${HYDRO_APPS_DIR} - -SWITCHES=($SWITCHES) -TESTCHECK="$TMCP_HOME/bin/getTestMode" -if [ -x ${TESTCHECK} ]; then - echo "Calling getTestMode()" - ${TESTCHECK} - status=${?} - if [ $status -eq 11 ]; then - MODE="TEST" - SWITCHES+=(-mode TEST) - elif [ $status -eq 12 ];then - MODE="PRACTICE" - SWITCHES+=(-mode PRACTICE) - elif [ $status -eq 15 ];then - MODE="OPERATIONAL" - SWITCHES+=(-mode OPERATIONAL) - else - MODE="OPERATIONAL (no response)" - fi - echo "getTestMode() returned ${MODE}" -else - MODE="UNKNOWN" - echo "getTestMode() not found - going to use defaults" -fi - -export TEXTWS=`hostname | sed -e 's/lx/xt/g'` - -hostName=`hostname -s` - -# check number of running caves -if [[ -z $IGNORE_NUM_CAVES ]]; then - # get total memory on system in bytes - mem=( `free -b | grep "Mem:"` ) - mem=${mem[1]} - # get max amount of system memory used before we warn - memThreshold=$(echo "$mem * $MAX_MEM_PROPORTION" | bc) - # remove decimal - printf -v memThreshold "%.0f" "$memThreshold" - # get launcher.ini argument determined by user arguments - lookupINI "$@" - launcherRegex='--launcher.ini\s(.+\.ini)' - # default to cave.ini - targetIni="/awips2/cave/cave.ini" - if [[ $CAVE_INI_ARG =~ $launcherRegex ]] - then - targetIni="${BASH_REMATCH[1]}" - fi - # read max memory that could be used by this instance - memOfLaunchingCave=$(readMemFromIni "$targetIni") - # read total max memory of caves already running - getTotalMemOfRunningCaves - # add them together - _totalAfterStart=$(($memOfLaunchingCave + $_totalRunningMem)) - if [[ "$_totalAfterStart" -ge "$memThreshold" ]]; then - # convert to megs for display - memOfLaunchingCave=$(($memOfLaunchingCave / $BYTES_IN_MB)) - _totalRunningMem=$(($_totalRunningMem / $BYTES_IN_MB)) - getPidsOfMyRunningCaves - memMsg="$_numPids CAVE applications already running with a combined max memory of ${_totalRunningMem}MB. " - memMsg+="The requested application has a max memory requirement of ${memOfLaunchingCave}MB. " - memMsg+="Starting may impact system performance and stability.\n\nProceed?" - zenity --question --title "Low Available Memory for Application" --text "$memMsg" - cancel="$?" - - if [[ "$cancel" == "1" ]]; then - exit - fi - fi -fi - -#check for gtk-2.0 value -gtkResource=.gtkrc-2.0 -includeLine="include \"$HOME/.gtkrc.mine\"" -mineFile=.gtkrc.mine -altButtonLine="gtk-alternative-button-order=1" -if [ -f $HOME/$gtkResource ]; then - if [ -w $HOME/$gtkResource ]; then - var=`grep "gtkrc.mine" $HOME/$gtkResource` - if [ '' == "$var" ]; then - echo $includeLine >> $HOME/$gtkResource - fi - fi -else - touch $HOME/$gtkResource - echo $includeLine >> $HOME/$gtkResource -fi - -if [ -f $HOME/$mineFile ]; then - if [ -w $HOME/$mineFile ]; then - var=`grep "alternative-button-order" $HOME/$mineFile` - if [ '' == "$var" ]; then - echo $altButtonLine >> $HOME/$mineFile - fi - fi -else - touch $HOME/$mineFile - echo $altButtonLine >> $HOME/$mineFile -fi - -if [[ -z "$PROGRAM_NAME" ]] -then - PROGRAM_NAME="cave" -fi - -BASE_LOGDIR=caveData/logs/consoleLogs -# Logback configuration files will append user.home to LOGDIR. -export LOGDIR=$BASE_LOGDIR/$hostName/ -FULL_LOGDIR=$HOME/$LOGDIR - -# make sure directory exists -if [ ! -d $FULL_LOGDIR ]; then - mkdir -p $FULL_LOGDIR -fi - -# delete any old disk caches in the background -deleteOldCaveLogs & - -curTime=`date +%Y%m%d_%H%M%S` - -pid=$! -export LOGFILE_STARTUP_SHUTDOWN="$FULL_LOGDIR/${PROGRAM_NAME}_${pid}_${curTime}_pid_%PID%_startup-shutdown.log" - -createEclipseConfigurationDir - -# At this point fork so that log files can be set up with the process pid and -# this process can log the exit status of cave. -( - # can we write to log directory - if [ -w $FULL_LOGDIR ]; then - touch ${LOGFILE_STARTUP_SHUTDOWN} - fi - - # remove "-noredirect" flag from command-line if set so it doesn't confuse any - # commands we call later. - redirect="true" - USER_ARGS=() - while [[ $1 ]] - do - if [[ "$1" == "-noredirect" ]] - then - redirect="false" - else - USER_ARGS+=("$1") - fi - shift - done - - lookupINI "${USER_ARGS[@]}" - - # Make it easy to determine which process is using the directory - if [[ -n $eclipseConfigurationDir ]]; then - echo "$$" > "$eclipseConfigurationDir"/pid - fi - - if [[ "${runMonitorThreads}" == "true" ]] ; then - # nohup to allow tar process to continue after user has logged out - nohup ${CAVE_INSTALL}/monitorThreads.sh $pid >> /dev/null 2>&1 & - fi - - echo "Launching cave application using the following command: " >> ${LOGFILE_STARTUP_SHUTDOWN} - echo "${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES[@]} ${USER_ARGS[@]}" >> ${LOGFILE_STARTUP_SHUTDOWN} - - 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 - # 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=$! -logExitStatus $pid $LOGFILE_STARTUP_SHUTDOWN - +/awips2/cave/run.sh -alertviz -component thinclient diff --git a/cave/build/static/linux/cave/run.sh b/cave/build/static/linux/cave/run.sh new file mode 100644 index 0000000000..d66638fcbf --- /dev/null +++ b/cave/build/static/linux/cave/run.sh @@ -0,0 +1,227 @@ +#!/bin/bash +# CAVE startup script +# Note: CAVE will not run as 'root' + +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +# +# +# SOFTWARE HISTORY +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# Dec 05, 2013 #2593 rjpeter Added check for number of running +# cave sessions. +# Dec 05, 2013 #2590 dgilling Modified so gfeclient.sh can be wrapped +# 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 +# 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 +# Jan 28, 2015 #4018 randerso Added a productEditor log file to changes in the GFE product editor +# Jun 17, 2015 #4148 rferrel Logback needs fewer environment variables. +# Jul 23, 2015 ASM#13849 D. Friedman Use a unique Eclipse configuration directory +# Aug 03, 2015 #4694 dlovely Logback will now add user.home to LOGDIR +# + + +user=`/usr/bin/whoami` +if [ ${user} == 'root' ];then + echo "WARNING: CAVE cannot be run as user '${user}'!" + echo " change to another user and run again." + exit 1 +fi + +# Since, we no longer need to worry about re-location ... +CAVE_INSTALL="/awips2/cave" +JAVA_INSTALL="/awips2/java" +PYTHON_INSTALL="/awips2/python" +export AWIPS_INSTALL_DIR="${CAVE_INSTALL}" + +MAX_MEM_PROPORTION="0.85" + +source ${CAVE_INSTALL}/caveUtil.sh +RC=$? +if [ ${RC} -ne 0 ]; then + echo "ERROR: unable to find and/or access ${CAVE_INSTALL}/caveUtil.sh." + exit 1 +fi + +# Run monitorThreads? +runMonitorThreads=false + +# copy the viz shutdown utility if necessary. +copyVizShutdownUtilIfNecessary + +# delete any old disk caches in the background +deleteOldCaveDiskCaches & + +# Enable core dumps +ulimit -c unlimited >> /dev/null 2>&1 + +export LD_LIBRARY_PATH=${JAVA_INSTALL}/lib:${PYTHON_INSTALL}/lib:$LD_LIBRARY_PATH +if [[ -z "$CALLED_EXTEND_LIB_PATH" ]]; then + extendLibraryPath +fi +export PATH=${JAVA_INSTALL}/bin:${PYTHON_INSTALL}/bin:$PATH +export JAVA_HOME="${JAVA_INSTALL}/jre" + +# The user can update this field if they choose to do so. +export HYDRO_APPS_DIR="/awips2/edex/data/share/hydroapps" + +export EDEX_HOME=/awips2/edex +export LOCALIZATION_ROOT=~/caveData/common +export PGSQL_DRIVER_DIR=`ls -1d /awips2/cave/plugins/org.postgres_*` +if [ $? -ne 0 ]; then + echo "FATAL: Unable to locate the PostgreSQL JDBC Driver." + exit 1 +fi +export apps_dir=${HYDRO_APPS_DIR} + +SWITCHES=($SWITCHES) +TESTCHECK="$TMCP_HOME/bin/getTestMode" +if [ -x ${TESTCHECK} ]; then + echo "Calling getTestMode()" + ${TESTCHECK} + status=${?} + if [ $status -eq 11 ]; then + MODE="TEST" + SWITCHES+=(-mode TEST) + elif [ $status -eq 12 ];then + MODE="PRACTICE" + SWITCHES+=(-mode PRACTICE) + elif [ $status -eq 15 ];then + MODE="OPERATIONAL" + SWITCHES+=(-mode OPERATIONAL) + else + MODE="OPERATIONAL (no response)" + fi + echo "getTestMode() returned ${MODE}" +else + MODE="UNKNOWN" + echo "getTestMode() not found - going to use defaults" +fi + +export TEXTWS=`hostname | sed -e 's/lx/xt/g'` + +hostName=`hostname -s` + +#check for gtk-2.0 value +gtkResource=.gtkrc-2.0 +includeLine="include \"$HOME/.gtkrc.mine\"" +mineFile=.gtkrc.mine +altButtonLine="gtk-alternative-button-order=1" +if [ -f $HOME/$gtkResource ]; then + if [ -w $HOME/$gtkResource ]; then + var=`grep "gtkrc.mine" $HOME/$gtkResource` + if [ '' == "$var" ]; then + echo $includeLine >> $HOME/$gtkResource + fi + fi +else + touch $HOME/$gtkResource + echo $includeLine >> $HOME/$gtkResource +fi + +if [ -f $HOME/$mineFile ]; then + if [ -w $HOME/$mineFile ]; then + var=`grep "alternative-button-order" $HOME/$mineFile` + if [ '' == "$var" ]; then + echo $altButtonLine >> $HOME/$mineFile + fi + fi +else + touch $HOME/$mineFile + echo $altButtonLine >> $HOME/$mineFile +fi + +if [[ -z "$PROGRAM_NAME" ]] +then + PROGRAM_NAME="cave" +fi + +BASE_LOGDIR=caveData/logs/consoleLogs +# Logback configuration files will append user.home to LOGDIR. +export LOGDIR=$BASE_LOGDIR/$hostName/ +FULL_LOGDIR=$HOME/$LOGDIR + +# make sure directory exists +if [ ! -d $FULL_LOGDIR ]; then + mkdir -p $FULL_LOGDIR +fi + +# delete any old disk caches in the background +deleteOldCaveLogs & + +curTime=`date +%Y%m%d_%H%M%S` + +pid=$! +export LOGFILE_STARTUP_SHUTDOWN="$FULL_LOGDIR/${PROGRAM_NAME}_${pid}_${curTime}_pid_%PID%_startup-shutdown.log" + +createEclipseConfigurationDir + +# At this point fork so that log files can be set up with the process pid and +# this process can log the exit status of cave. +( + # can we write to log directory + if [ -w $FULL_LOGDIR ]; then + touch ${LOGFILE_STARTUP_SHUTDOWN} + fi + + # remove "-noredirect" flag from command-line if set so it doesn't confuse any + # commands we call later. + redirect="true" + USER_ARGS=() + while [[ $1 ]] + do + if [[ "$1" == "-noredirect" ]] + then + redirect="false" + else + USER_ARGS+=("$1") + fi + shift + done + + lookupINI "${USER_ARGS[@]}" + + # Make it easy to determine which process is using the directory + if [[ -n $eclipseConfigurationDir ]]; then + echo "$$" > "$eclipseConfigurationDir"/pid + fi + + if [[ "${runMonitorThreads}" == "true" ]] ; then + # nohup to allow tar process to continue after user has logged out + nohup ${CAVE_INSTALL}/monitorThreads.sh $pid >> /dev/null 2>&1 & + fi + + echo "Launching cave application using the following command: " >> ${LOGFILE_STARTUP_SHUTDOWN} + echo "${CAVE_INSTALL}/cave ${CAVE_INI_ARG} ${SWITCHES[@]} ${USER_ARGS[@]}" >> ${LOGFILE_STARTUP_SHUTDOWN} + + 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 + # 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=$! +logExitStatus $pid $LOGFILE_STARTUP_SHUTDOWN + diff --git a/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.csh b/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.csh index 9f7c7ae4e2..efe926e78c 100755 --- a/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.csh +++ b/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.csh @@ -1,4 +1,5 @@ #!/bin/csh +alias cave /awips2/cave/run.sh -alertviz -component thinclient set JAVA_INSTALL="/awips2/java" set PYTHON_INSTALL="/awips2/python" set NOTIFICATION_INSTALL="/awips2/notification" diff --git a/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.sh b/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.sh index a49b7bcaa4..ff18c76d96 100755 --- a/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.sh +++ b/rpms/awips2.core/Installer.version/scripts/profile.d/awips2.sh @@ -1,5 +1,5 @@ #!/bin/bash - +alias cave='/awips2/cave/run.sh -alertviz -component thinclient' PYTHON_INSTALL="/awips2/python" CLI_INSTALL="/awips2/fxa" GFESUITE_PATH="/awips2/GFESuite/bin"