Omaha #4148 Changes to script to use fewer env variables and update logback files.

Change-Id: I8b5b82c4ee371ab10c571a6075c71143bb9e0100

Former-commit-id: 20c1d6c1851012b49f18d43aa6203e4dc51cbd72
This commit is contained in:
Roger Ferrel 2015-06-17 16:18:05 -05:00
parent 39b33b12a9
commit 9eebfd0c0e
5 changed files with 43 additions and 77 deletions

View file

@ -26,6 +26,7 @@
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# Oct 09, 2014 #3675 bclement added cleanExit signal trap # Oct 09, 2014 #3675 bclement added cleanExit signal trap
# Jun 17, 2015 #4148 rferrel Logback needs fewer environment variables.
# #
user=`/usr/bin/whoami` user=`/usr/bin/whoami`
@ -96,7 +97,7 @@ fi
#check for the logs directory, which may not be present at first start #check for the logs directory, which may not be present at first start
hostName=`hostname -s` hostName=`hostname -s`
LOGDIR=$HOME/caveData/logs/consoleLogs/$hostName/ export LOGDIR=$HOME/caveData/logs/consoleLogs/$hostName/
if [ ! -d $LOGDIR ]; then if [ ! -d $LOGDIR ]; then
mkdir -p $LOGDIR mkdir -p $LOGDIR
@ -122,27 +123,17 @@ trap 'cleanExit $pid' SIGHUP SIGINT SIGQUIT SIGTERM
count=0 count=0
while [ $exitVal -ne 0 -a $count -lt 10 ] while [ $exitVal -ne 0 -a $count -lt 10 ]
do do
count=`expr $count + 1` count=`expr $count + 1`
curTime=`date +%Y%m%d_%H%M%S` #check for display; if no display then exit
LOGFILE=${LOGDIR}/alertviz_${curTime}_console.log if [ -z "${DISPLAY}" ]; then
export LOGFILE_ALERTVIZ=${LOGDIR}/alertviz_${curTime}_admin.log echo "Display is not available."
exitVal=0
#first check if we can write to the directory
if [ -w ${LOGDIR} ]; then
touch ${LOGFILE}
fi
#check for display; if no display then exit
if [ -z "${DISPLAY}" ]; then
echo "Display is not available."
exitVal=0
else
#finally check if we can write to the file
if [ -w ${LOGFILE} ]; then
${dir}/alertviz $* > ${LOGFILE} 2>&1 &
else else
${dir}/alertviz $* & if [ -w ${LOGDIR} ] ; then
fi ${dir}/alertviz $* > /dev/null 2>&1 &
else
${dir}/alertviz $* &
fi
pid=$! pid=$!
wait $pid wait $pid
exitVal=$? exitVal=$?

View file

@ -34,6 +34,7 @@
# Oct 10, 2014 #3675 njensen Logback now does console logging to ensure correct pid # 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 # 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 # 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.
# #
@ -194,7 +195,7 @@ then
fi fi
BASE_LOGDIR=$HOME/caveData/logs/consoleLogs BASE_LOGDIR=$HOME/caveData/logs/consoleLogs
LOGDIR=$BASE_LOGDIR/$hostName/ export LOGDIR=$BASE_LOGDIR/$hostName/
# make sure directory exists # make sure directory exists
if [ ! -d $LOGDIR ]; then if [ ! -d $LOGDIR ]; then
@ -212,13 +213,6 @@ export LOGFILE_STARTUP_SHUTDOWN="${LOGDIR}/${PROGRAM_NAME}_${pid}_${curTime}_pid
# At this point fork so that log files can be set up with the process pid and # 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. # this process can log the exit status of cave.
( (
# we include the PID of the launching process along with
# a %PID% placeholder to be replaced with the "real" PID
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"
export LOGFILE_PRODUCT_EDITOR="${LOGDIR}/${PROGRAM_NAME}_${curTime}_pid_%PID%_productEditor.log"
# can we write to log directory # can we write to log directory
if [ -w ${LOGDIR} ]; then if [ -w ${LOGDIR} ]; then
touch ${LOGFILE_STARTUP_SHUTDOWN} touch ${LOGFILE_STARTUP_SHUTDOWN}

View file

@ -25,27 +25,15 @@ SET JavaJreDirectory=
REM Determine where we will be logging to. REM Determine where we will be logging to.
SET HOME_DIRECTORY=%USERPROFILE% SET HOME_DIRECTORY=%USERPROFILE%
SET CAVEDATA_LOG_DIRECTORY=%HOME_DIRECTORY%\caveData\logs
SET CONSOLE_LOG_DIRECTORY=%CAVEDATA_LOG_DIRECTORY%\consoleLogs\%COMPUTERNAME% REM Use by logback configuration files to determine console and admin
IF NOT EXIST "%CONSOLE_LOG_DIRECTORY%" (MKDIR "%CONSOLE_LOG_DIRECTORY%") SET LOGDIR=%HOME_DIRECTORY%\caveData\logs
echo Starting ALERTVIZ; leave this CMD window open to enable AlertViz 'restart'. echo Starting ALERTVIZ; leave this CMD window open to enable AlertViz 'restart'.
REM Start AlertViz (and implement the alertviz restart capability). REM Start AlertViz (and implement the alertviz restart capability).
:AlertVizLoopStart :AlertVizLoopStart
SET RND=%random%
SET RND_DATETIME_FILE=%TMP%\awips2dt_%RND%.tmp
REM Python is used to retrieve the current date and time because the order
REM of the Windows date/time fields is not necessarily guaranteed and the
REM Windows date/time fields can only be extracted using substring operations
REM instead of -formatter- strings like Linux allows.
python -c "from datetime import datetime; print datetime.now().strftime('%%Y%%m%%d_%%H%%M%%S');" > %RND_DATETIME_FILE%
SET /p LOG_DATETIME= < %RND_DATETIME_FILE%
DEL %RND_DATETIME_FILE%
SET LOGFILE_CONSOLE=%CAVEDATA_LOG_DIRECTORY%\alertviz_%LOG_DATETIME%_console.log "%CONTAINING_DIRECTORY%alertviz.exe" %*
SET LOGFILE_ALERTVIZ=%CAVEDATA_LOG_DIRECTORY%\alertviz_%LOG_DATETIME%_admin.log
"%CONTAINING_DIRECTORY%alertviz.exe" %* > "%CONSOLE_LOG_DIRECTORY%\alertviz_%LOG_DATETIME%.log" 2>&1
IF %ERRORLEVEL% == 0 (EXIT) IF %ERRORLEVEL% == 0 (EXIT)
echo Restarting AlertViz. echo Restarting AlertViz.
GOTO AlertVizLoopStart GOTO AlertVizLoopStart

View file

@ -28,29 +28,14 @@ SET JavaJreDirectory=
REM Determine where we will be logging to. REM Determine where we will be logging to.
SET HOME_DIRECTORY=%USERPROFILE% SET HOME_DIRECTORY=%USERPROFILE%
SET CAVEDATA_LOG_DIRECTORY=%HOME_DIRECTORY%\caveData\logs
SET CONSOLE_LOG_DIRECTORY=%CAVEDATA_LOG_DIRECTORY%\consoleLogs\%COMPUTERNAME%
IF NOT EXIST "%CONSOLE_LOG_DIRECTORY%" (MKDIR "%CONSOLE_LOG_DIRECTORY%")
SET RND=%random% REM Used by logback configuration files to determine console and admin
SET RND_DATETIME_FILE=%TMP%\awips2dt_%RND%.tmp SET LOGDIR=%HOME_DIRECTORY%\caveData\logs
REM Python is used to retrieve the current date and time because the order
REM of the Windows date/time fields is not necessarily guaranteed and the
REM Windows date/time fields can only be extracted using substring operations
REM instead of -formatter- strings like Linux allows.
python -c "from datetime import datetime; print datetime.now().strftime('%%Y%%m%%d_%%H%%M%%S');" > %RND_DATETIME_FILE%
SET /p LOG_DATETIME= < %RND_DATETIME_FILE%
DEL %RND_DATETIME_FILE%
SET LOGFILE_CAVE=%CAVEDATA_LOG_DIRECTORY%\cave_%LOG_DATETIME%_logs.log
SET LOGFILE_CONSOLE=%CAVEDATA_LOG_DIRECTORY%\cave_%LOG_DATETIME%_console.log
SET LOGFILE_PERFORMANCE=%CAVEDATA_LOG_DIRECTORY%\cave_%LOG_DATETIME%_perf.log
SET LOGFILE_PRODUCT_EDITOR=%CAVEDATA_LOG_DIRECTORY%\cave_%LOG_DATETIME%_productEditor.log
echo THIS CMD WINDOW CAN BE CLOSED AT ANY TIME! echo THIS CMD WINDOW CAN BE CLOSED AT ANY TIME!
cd %HOMEPATH% cd %HOMEPATH%
REM Start CAVE. REM Start CAVE.
"%CONTAINING_DIRECTORY%cave.exe" %* > "%CONSOLE_LOG_DIRECTORY%\cave_%LOG_DATETIME%.log" 2>&1 "%CONTAINING_DIRECTORY%cave.exe" %*
IF ERRORLEVEL 1 (echo CAVE ERROR - check the logs for additional information. && PAUSE) IF ERRORLEVEL 1 (echo CAVE ERROR - check the logs for additional information. && PAUSE)
EXIT EXIT

View file

@ -2,9 +2,20 @@
<!-- Only define when not wanting to use the UF Standard. <!-- Only define when not wanting to use the UF Standard.
<property scope="context" name="log.message.pattern" value="%-5p %d [%t] %c{0}: %m%n"/> <property scope="context" name="log.message.pattern" value="%-5p %d [%t] %c{0}: %m%n"/>
--> -->
<timestamp key="startTime" datePattern="yyyyMMdd_HHmmss" />
<define name="adminLogFile" class="com.raytheon.uf.common.logback.LogFilePropertyDefiner" >
<directory>${LOGDIR}</directory>
<name>alertviz_${startTime}_admin.log</name>
</define>
<define name="consoleLogFile" class="com.raytheon.uf.common.logback.LogFilePropertyDefiner" >
<directory>${LOGDIR}</directory>
<name>alertviz_${startTime}_console.log</name>
</define>
<!-- general application log --> <!-- general application log -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/> <encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/>
<!-- In eclipse InvertedThresholdFilter allows different color display for console and errConsole. -->
<filter class="com.raytheon.uf.common.logback.filter.InvertedThresholdFilter"> <filter class="com.raytheon.uf.common.logback.filter.InvertedThresholdFilter">
<level>INFO</level> <level>INFO</level>
</filter> </filter>
@ -18,20 +29,16 @@
<encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/> <encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/>
</appender> </appender>
<appender name="AlertVizAdminLogAppender" class="com.raytheon.uf.common.logback.appender.EnvConfigurableRollingFileAppender"> <appender name="consoleLog" class="com.raytheon.uf.common.logback.appender.ConsoleFileAppender">
<!-- file and fileNamePattern will be overridden by the env variable if present, but are required by logback --> <encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/>
<file>alertviz-admin.log</file> <file>${consoleLogFile}</file>
<envLogVar>LOGFILE_ALERTVIZ</envLogVar> <filter class="com.raytheon.uf.common.logback.filter.InvertedThresholdFilter">
<rollingPolicy class="com.raytheon.uf.common.logback.policy.EnvConfigurableFixedWindowRollingPolicy"> <level>INFO</level>
<fileNamePattern>alertviz-admin.log%i</fileNamePattern> </filter>
<envLogVar>LOGFILE_ALERTVIZ</envLogVar> </appender>
<minIndex>1</minIndex>
<maxIndex>5</maxIndex> <appender name="AlertVizAdminLogAppender" class="ch.qos.logback.core.FileAppender">
</rollingPolicy> <file>${adminLogFile}</file>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>2GB</maxFileSize>
</triggeringPolicy>
<append>true</append>
<encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/> <encoder class="com.raytheon.uf.common.logback.encoder.UFStdEncoder"/>
</appender> </appender>
@ -71,5 +78,6 @@
<level value="INFO"/> <level value="INFO"/>
<appender-ref ref="console"/> <appender-ref ref="console"/>
<appender-ref ref="errConsole"/> <appender-ref ref="errConsole"/>
<appender-ref ref="consoleLog"/>
</root> </root>
</configuration> </configuration>