Skip to content

Commit

Permalink
[script] auto heap dump when oom error (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 authored Feb 21, 2023
1 parent 9ac13d0 commit b26745c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions script/assembly/server/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if [ ! -d $LOGS_DIR ]; then
fi

# JVM Configuration
JAVA_MEM_OPTS=" -server -XX:SurvivorRatio=6 -XX:+UseParallelGC "
JAVA_MEM_OPTS=" -server -XX:SurvivorRatio=6 -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$LOGS_DIR"

# 加载外部log文件的配置
LOG_IMPL_FILE=logback-spring.xml
Expand All @@ -55,4 +55,4 @@ then
fi
CONFIG_FILES=" -Dlogging.path=$LOGS_DIR $LOGGING_CONFIG -Dspring.config.location=$CONF_DIR/ "
echo -e "Starting the HertzBeat $SERVER_NAME ..."
java $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME --spring.profiles.active=prod
java $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME --spring.profiles.active=prod
10 changes: 5 additions & 5 deletions script/assembly/server/bin/startup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@rem

@title HertzBeat
@echo off
@echo off
setlocal enabledelayedexpansion

set SERVER_NAME=${project.artifactId}
Expand All @@ -29,7 +29,7 @@ cd /d %~dp0
cd ..

set DEPLOY_DIR=%~dp0..
echo %DEPLOY_DIR%
echo %DEPLOY_DIR%

set CONF_DIR=%DEPLOY_DIR%\config
echo %CONF_DIR%
Expand All @@ -51,7 +51,7 @@ if not exist %LOGS_DIR% (
rem JVM Configuration
set JAVA_OPTS= -Duser.timezone=Asia/Shanghai

set JAVA_MEM_OPTS= -server -XX:SurvivorRatio=6 -XX:+UseParallelGC
set JAVA_MEM_OPTS= -server -XX:SurvivorRatio=6 -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%LOGS_DIR%


set LOGGING_CONFIG=-Dlogging.config=%CONF_DIR%\logback-spring.xml
Expand All @@ -63,9 +63,9 @@ start javaw %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -jar %DEPLOY_DIR%\%JAR_NA

echo "Service Start Success!"
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%SERVER_PORT%"') do (
echo Service PID: %%m , Port %SERVER_PORT%
echo Service PID: %%m , Port %SERVER_PORT%
goto q
)

:q
pause
pause
4 changes: 2 additions & 2 deletions script/assembly/server/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fi
# JVM Configuration
JAVA_OPTS=" -Duser.timezone=Asia/Shanghai"

JAVA_MEM_OPTS=" -server -XX:SurvivorRatio=6 -XX:+UseParallelGC "
JAVA_MEM_OPTS=" -server -XX:SurvivorRatio=6 -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$LOGS_DIR"

# 加载外部log文件的配置
LOG_IMPL_FILE=logback-spring.xml
Expand Down Expand Up @@ -114,4 +114,4 @@ done

echo "Service Start Success!"
PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "Service PID: $PIDS"
echo "Service PID: $PIDS"

0 comments on commit b26745c

Please sign in to comment.