Add ability to control debug suspend mode to kc scripts

We now consider the new env variable DEBUG_SUSPEND to control the
suspend mode of the remote debug configuration. DEBUG_SUSPEND defaults to 'n' which was the hard-coded default setting before.

Fixes #10178

Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
This commit is contained in:
Thomas Darimont 2022-02-13 14:01:23 +01:00 committed by Pedro Igor
parent cfddcad3c5
commit 61ea2dd1bb
2 changed files with 12 additions and 2 deletions

View file

@ -23,6 +23,7 @@ set "SERVER_OPTS=-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dq
set DEBUG_MODE=false set DEBUG_MODE=false
set DEBUG_PORT_VAR=8787 set DEBUG_PORT_VAR=8787
set DEBUG_SUSPEND_VAR=n
rem Read command-line args, the ~ removes the quotes from the parameter rem Read command-line args, the ~ removes the quotes from the parameter
:READ-ARGS :READ-ARGS
@ -36,6 +37,9 @@ if "%KEY%" == "--debug" (
if "%DEBUG_PORT_VAR%" == "" ( if "%DEBUG_PORT_VAR%" == "" (
set DEBUG_PORT_VAR=8787 set DEBUG_PORT_VAR=8787
) )
if "%DEBUG_SUSPEND_VAR%" == "" (
set DEBUG_SUSPEND_VAR=n
)
shift shift
shift shift
goto READ-ARGS goto READ-ARGS
@ -84,11 +88,16 @@ if NOT "x%DEBUG%" == "x" (
if NOT "x%DEBUG_PORT%" == "x" ( if NOT "x%DEBUG_PORT%" == "x" (
set DEBUG_PORT_VAR=%DEBUG_PORT% set DEBUG_PORT_VAR=%DEBUG_PORT%
) )
if NOT "x%DEBUG_SUSPEND%" == "x" (
set DEBUG_SUSPEND_VAR=%DEBUG_SUSPEND%
)
rem Set debug settings if not already set rem Set debug settings if not already set
if "%DEBUG_MODE%" == "true" ( if "%DEBUG_MODE%" == "true" (
echo "%JAVA_OPTS%" | findstr /I "\-agentlib:jdwp" > nul echo "%JAVA_OPTS%" | findstr /I "\-agentlib:jdwp" > nul
if errorlevel == 1 ( if errorlevel == 1 (
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT_VAR%,server=y,suspend=n" set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT_VAR%,server=y,suspend=%DEBUG_SUSPEND_VAR%"
) else ( ) else (
echo Debug already enabled in JAVA_OPTS, ignoring --debug argument echo Debug already enabled in JAVA_OPTS, ignoring --debug argument
) )

View file

@ -27,6 +27,7 @@ SERVER_OPTS="-Dkc.home.dir=$DIRNAME/../ -Djboss.server.config.dir=$DIRNAME/../co
DEBUG_MODE="${DEBUG:-false}" DEBUG_MODE="${DEBUG:-false}"
DEBUG_PORT="${DEBUG_PORT:-8787}" DEBUG_PORT="${DEBUG_PORT:-8787}"
DEBUG_SUSPEND="${DEBUG_SUSPEND:-n}"
CONFIG_ARGS=${CONFIG_ARGS:-""} CONFIG_ARGS=${CONFIG_ARGS:-""}
@ -77,7 +78,7 @@ fi
if [ "$DEBUG_MODE" = "true" ]; then if [ "$DEBUG_MODE" = "true" ]; then
DEBUG_OPT=`echo $JAVA_OPTS | $GREP "\-agentlib:jdwp"` DEBUG_OPT=`echo $JAVA_OPTS | $GREP "\-agentlib:jdwp"`
if [ "x$DEBUG_OPT" = "x" ]; then if [ "x$DEBUG_OPT" = "x" ]; then
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n" JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=$DEBUG_SUSPEND"
else else
echo "Debug already enabled in JAVA_OPTS, ignoring --debug argument" echo "Debug already enabled in JAVA_OPTS, ignoring --debug argument"
fi fi