[jboss-cvs] JBossAS SVN: r114745 - branches/JBPAPP_5/main/src/bin.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 24 23:19:37 EST 2014
Author: aogburn
Date: 2014-02-24 23:19:36 -0500 (Mon, 24 Feb 2014)
New Revision: 114745
Modified:
branches/JBPAPP_5/main/src/bin/run.bat
branches/JBPAPP_5/main/src/bin/run.sh
Log:
[EAP5-57] Enable Garbage Collection Logging by Default
Modified: branches/JBPAPP_5/main/src/bin/run.bat
===================================================================
--- branches/JBPAPP_5/main/src/bin/run.bat 2014-02-24 08:02:30 UTC (rev 114744)
+++ branches/JBPAPP_5/main/src/bin/run.bat 2014-02-25 04:19:36 UTC (rev 114745)
@@ -90,6 +90,54 @@
)
)
+rem Setup directories, note directories with spaces do not work
+set "CONSOLIDATED_OPTS=%JAVA_OPTS% %ARGS%"
+:DIRLOOP
+echo(%CONSOLIDATED_OPTS% | findstr /r /c:"^-Djboss.server.base.dir" > nul && (
+ for /f "tokens=1,2* delims==" %%a IN ("%CONSOLIDATED_OPTS%") DO (
+ for /f %%i IN ("%%b") DO set "JBOSS_BASE_DIR=%%~fi"
+ )
+)
+echo(%CONSOLIDATED_OPTS% | findstr /r /c:"^-Djboss.server.log.dir" > nul && (
+ for /f "tokens=1,2* delims==" %%a IN ("%CONSOLIDATED_OPTS%") DO (
+ for /f %%i IN ("%%b") DO set "JBOSS_LOG_DIR=%%~fi"
+ )
+)
+
+for /f "tokens=1* delims= " %%i IN ("%CONSOLIDATED_OPTS%") DO (
+ if %%i == "" (
+ goto ENDDIRLOOP
+ ) else (
+ set CONSOLIDATED_OPTS=%%j
+ GOTO DIRLOOP
+ )
+)
+
+:ENDDIRLOOP
+
+rem Set the log dir if it hasn't been already
+if "x%JBOSS_LOG_DIR%" == "x" (
+ if not "x%JBOSS_BASE_DIR%" == "x" (
+ set "JBOSS_LOG_DIR=%JBOSS_BASE_DIR%\%PROFILE_DIR%\log"
+ ) else (
+ set "JBOSS_LOG_DIR=%JBOSS_HOME%\server\%PROFILE_DIR%\log"
+ )
+)
+
+rem Add rotating GC logs, if supported, and not already defined
+echo "%JAVA_OPTS%" | findstr /I "\-verbose:gc" > nul
+if errorlevel == 1 (
+ "%JAVA%" -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -version > nul 2>&1
+ if not errorlevel == 1 (
+ if not exist "%JBOSS_LOG_DIR%" > nul 2>&1 (
+ mkdir "%JBOSS_LOG_DIR%" > nul 2>&1
+ )
+ rem Back up any prior logs
+ rename "%JBOSS_LOG_DIR%\gc.log.*" "backupgc.log.?" > nul 2>&1
+ set "JAVA_OPTS=-verbose:gc -Xloggc:%JBOSS_LOG_DIR%\gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M %JAVA_OPTS%"
+ )
+)
+
rem Add -server to the JVM options, if supported
"%JAVA%" -server -version 2>&1 | findstr /I hotspot > nul
if not errorlevel == 1 (
Modified: branches/JBPAPP_5/main/src/bin/run.sh
===================================================================
--- branches/JBPAPP_5/main/src/bin/run.sh 2014-02-24 08:02:30 UTC (rev 114744)
+++ branches/JBPAPP_5/main/src/bin/run.sh 2014-02-25 04:19:36 UTC (rev 114745)
@@ -35,6 +35,11 @@
JBOSS_BASE_DIR=`echo $SWITCH|sed 's/\-Djboss.server.base.dir=//'`
fi
+ echo "$SWITCH" | grep "^\-Djboss.server.log.dir=" #> /dev/null
+ if [ $? -eq 0 ]; then
+ JBOSS_LOG_DIR=`echo $SWITCH|sed 's/\-Djboss.server.log.dir=//'`
+ fi
+
echo "$SWITCH" | grep "^--run-conf=" > /dev/null
if [ $? -eq 0 ]; then
RUN_CONF=`echo $SWITCH|sed 's/--run-conf=//'`
@@ -273,6 +278,59 @@
fi
fi
+# Enable rotating GC logs if the JVM supports it and GC logs are not already enabled
+NO_GC_LOG_ROTATE=`echo $JAVA_OPTS | $GREP "\-verbose:gc"`
+if [ "x$NO_GC_LOG_ROTATE" = "x" ]; then
+ # Check JAVA_OPTS for a specified log directory
+ if $linux || $solaris; then
+ for var in $JAVA_OPTS
+ do
+ # Remove quotes
+ p=`echo $var | tr -d '"'`
+ case $p in
+ -Djboss.server.log.dir=*)
+ JBOSS_LOG_DIR=`readlink -m ${p#*=}`
+ ;;
+ esac
+ done
+ fi
+
+ # No readlink -m on BSD
+ if $darwin; then
+ for var in $JAVA_OPTS
+ do
+ # Remove quotes
+ p=`echo $var | tr -d '"'`
+ case $p in
+ -Djboss.server.log.dir=*)
+ JBOSS_LOG_DIR=`cd ${p#*=} ; pwd -P`
+ ;;
+ esac
+ done
+ fi
+
+ # Determine the log directory if not set already
+ if [ "x$JBOSS_LOG_DIR" = "x" ]; then
+ if [ "x$JBOSS_BASE_DIR" != "x" ]; then
+ JBOSS_LOG_DIR="$JBOSS_BASE_DIR/$JBOSSCONF/log"
+ else
+ JBOSS_LOG_DIR="$JBOSS_HOME/server/$JBOSSCONF/log"
+ fi
+ fi
+
+ # For Cygwin, switch paths to Windows format
+ if $cygwin; then
+ JBOSS_LOG_DIR=`cygpath --path --windows "$JBOSS_LOG_DIR"`
+ fi
+
+ # backup prior logs
+ for file in $JBOSS_LOG_DIR/gc.log.*
+ do
+ mv "$file" "$JBOSS_LOG_DIR/backupgc.log${file#*/gc.log}" >/dev/null 2>&1
+ done
+ "$JAVA" -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -version >/dev/null 2>&1 && mkdir -p $JBOSS_LOG_DIR && JAVA_OPTS="-verbose:gc -Xloggc:$JBOSS_LOG_DIR/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M $JAVA_OPTS"
+fi
+
# Setup JBoss specific properties
JAVA_OPTS="-Dprogram.name=$PROGNAME $JAVA_OPTS"
More information about the jboss-cvs-commits
mailing list