jboss/bin/standalone.bat in torquebox-lite-0.2.2 vs jboss/bin/standalone.bat in torquebox-lite-0.3.0
- old
+ new
@@ -1,32 +1,65 @@
@echo off
rem -------------------------------------------------------------------------
rem JBoss Bootstrap Script for Windows
rem -------------------------------------------------------------------------
-rem $Id$
+rem Use --debug to activate debug mode with an optional argument to specify the port
+rem Usage : standalone.bat --debug
+rem standalone.bat --debug 9797
+rem By default debug mode is disable.
+set DEBUG_MODE=false
+set DEBUG_PORT=8787
+rem Set to all parameters by default
+set SERVER_OPTS=%*
+
+rem Get the program name before using shift as the command modify the variable ~nx0
+if "%OS%" == "Windows_NT" (
+ set "PROGNAME=%~nx0%"
+) else (
+ set "PROGNAME=standalone.bat"
+)
+
@if not "%ECHO%" == "" echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal
if "%OS%" == "Windows_NT" (
set "DIRNAME=%~dp0%"
) else (
set DIRNAME=.\
)
-rem Read an optional configuration file.
-if "x%STANDALONE_CONF%" == "x" (
- set "STANDALONE_CONF=%DIRNAME%standalone.conf.bat"
-)
-if exist "%STANDALONE_CONF%" (
- echo Calling "%STANDALONE_CONF%"
- call "%STANDALONE_CONF%" %*
+rem Read command-line args.
+:READ-ARGS
+if "%1" == "" (
+ goto MAIN
+) else if "%1" == "--debug" (
+ goto READ-DEBUG-PORT
) else (
- echo Config file not found "%STANDALONE_CONF%"
+ rem This doesn't work as Windows splits on = and spaces by default
+ rem set SERVER_OPTS=%SERVER_OPTS% %1
+ shift
+ goto READ-ARGS
)
+:READ-DEBUG-PORT
+set "DEBUG_MODE=true"
+set DEBUG_ARG="%2"
+if not "x%DEBUG_ARG" == "x" (
+ if x%DEBUG_ARG:-=%==x%DEBUG_ARG% (
+ shift
+ set DEBUG_PORT=%DEBUG_ARG%
+ )
+ shift
+ goto READ-ARGS
+)
+
+:MAIN
+rem $Id$
+)
+
pushd %DIRNAME%..
set "RESOLVED_JBOSS_HOME=%CD%"
popd
if "x%JBOSS_HOME%" == "x" (
@@ -35,22 +68,44 @@
pushd "%JBOSS_HOME%"
set "SANITIZED_JBOSS_HOME=%CD%"
popd
-if "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (
- echo WARNING JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
+if /i "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (
+ echo.
+ echo WARNING: JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
+ echo.
+ echo JBOSS_HOME: %JBOSS_HOME%
+ echo.
+ rem 2 seconds pause
+ ping 127.0.0.1 -n 3 > nul
)
-set DIRNAME=
-
-if "%OS%" == "Windows_NT" (
- set "PROGNAME=%~nx0%"
+rem Read an optional configuration file.
+if "x%STANDALONE_CONF%" == "x" (
+ set "STANDALONE_CONF=%DIRNAME%standalone.conf.bat"
+)
+if exist "%STANDALONE_CONF%" (
+ echo Calling "%STANDALONE_CONF%"
+ call "%STANDALONE_CONF%" %*
) else (
- set "PROGNAME=standalone.bat"
+ echo Config file not found "%STANDALONE_CONF%"
)
+
+rem Set debug settings if not already set
+if "%DEBUG_MODE%" == "true" (
+ echo "%JAVA_OPTS%" | findstr /I "\-agentlib:jdwp" > nul
+ if errorlevel == 1 (
+ echo Debug already enabled in JAVA_OPTS, ignoring --debug argument
+ ) else (
+ set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n"
+ )
+)
+
+set DIRNAME=
+
rem Setup JBoss specific properties
set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%
if "x%JAVA_HOME%" == "x" (
set JAVA=java
@@ -138,17 +193,17 @@
echo ===============================================================================
echo.
:RESTART
"%JAVA%" %JAVA_OPTS% ^
- "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\boot.log" ^
+ "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
"-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
-jar "%JBOSS_HOME%\jboss-modules.jar" ^
-mp "%JBOSS_MODULEPATH%" ^
-jaxpmodule "javax.xml.jaxp-provider" ^
org.jboss.as.standalone ^
-Djboss.home.dir="%JBOSS_HOME%" ^
- %*
+ %SERVER_OPTS%
if ERRORLEVEL 10 goto RESTART
:END
if "x%NOPAUSE%" == "x" pause