standalone.bat 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. @echo off
  2. rem -------------------------------------------------------------------------
  3. rem JBoss Bootstrap Script for Windows
  4. rem -------------------------------------------------------------------------
  5. rem Use --debug to activate debug mode with an optional argument to specify the port
  6. rem Usage : standalone.bat --debug
  7. rem standalone.bat --debug 9797
  8. rem By default debug mode is disable.
  9. set DEBUG_MODE=false
  10. set DEBUG_PORT=8787
  11. rem Set to all parameters by default
  12. set SERVER_OPTS=%*
  13. rem Get the program name before using shift as the command modify the variable ~nx0
  14. if "%OS%" == "Windows_NT" (
  15. set "PROGNAME=%~nx0%"
  16. ) else (
  17. set "PROGNAME=standalone.bat"
  18. )
  19. @if not "%ECHO%" == "" echo %ECHO%
  20. @if "%OS%" == "Windows_NT" setlocal
  21. if "%OS%" == "Windows_NT" (
  22. set "DIRNAME=%~dp0%"
  23. ) else (
  24. set DIRNAME=.\
  25. )
  26. rem Read command-line args.
  27. :READ-ARGS
  28. if "%1" == "" (
  29. goto MAIN
  30. ) else if "%1" == "--debug" (
  31. goto READ-DEBUG-PORT
  32. ) else (
  33. rem This doesn't work as Windows splits on = and spaces by default
  34. rem set SERVER_OPTS=%SERVER_OPTS% %1
  35. shift
  36. goto READ-ARGS
  37. )
  38. :READ-DEBUG-PORT
  39. set "DEBUG_MODE=true"
  40. set DEBUG_ARG="%2"
  41. if not "x%DEBUG_ARG" == "x" (
  42. if x%DEBUG_ARG:-=%==x%DEBUG_ARG% (
  43. shift
  44. set DEBUG_PORT=%DEBUG_ARG%
  45. )
  46. shift
  47. goto READ-ARGS
  48. )
  49. :MAIN
  50. rem $Id$
  51. )
  52. pushd %DIRNAME%..
  53. set "RESOLVED_JBOSS_HOME=%CD%"
  54. popd
  55. if "x%JBOSS_HOME%" == "x" (
  56. set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%"
  57. )
  58. pushd "%JBOSS_HOME%"
  59. set "SANITIZED_JBOSS_HOME=%CD%"
  60. popd
  61. if /i "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (
  62. echo.
  63. echo WARNING: JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
  64. echo.
  65. echo JBOSS_HOME: %JBOSS_HOME%
  66. echo.
  67. rem 2 seconds pause
  68. ping 127.0.0.1 -n 3 > nul
  69. )
  70. rem Read an optional configuration file.
  71. if "x%STANDALONE_CONF%" == "x" (
  72. set "STANDALONE_CONF=%DIRNAME%standalone.conf.bat"
  73. )
  74. if exist "%STANDALONE_CONF%" (
  75. echo Calling "%STANDALONE_CONF%"
  76. call "%STANDALONE_CONF%" %*
  77. ) else (
  78. echo Config file not found "%STANDALONE_CONF%"
  79. )
  80. rem Set debug settings if not already set
  81. if "%DEBUG_MODE%" == "true" (
  82. echo "%JAVA_OPTS%" | findstr /I "\-agentlib:jdwp" > nul
  83. if errorlevel == 1 (
  84. echo Debug already enabled in JAVA_OPTS, ignoring --debug argument
  85. ) else (
  86. set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n"
  87. )
  88. )
  89. set DIRNAME=
  90. rem Setup JBoss specific properties
  91. set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%
  92. if "x%JAVA_HOME%" == "x" (
  93. set JAVA=java
  94. echo JAVA_HOME is not set. Unexpected results may occur.
  95. echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
  96. ) else (
  97. set "JAVA=%JAVA_HOME%\bin\java"
  98. )
  99. if not "%PRESERVE_JAVA_OPTS%" == "true" (
  100. rem Add -client to the JVM options, if supported (32 bit VM), and not overriden
  101. echo "%JAVA_OPTS%" | findstr /I \-server > nul
  102. if errorlevel == 1 (
  103. "%JAVA%" -client -version 2>&1 | findstr /I /C:"Client VM" > nul
  104. if not errorlevel == 1 (
  105. set "JAVA_OPTS=-client %JAVA_OPTS%"
  106. )
  107. )
  108. )
  109. if not "%PRESERVE_JAVA_OPTS%" == "true" (
  110. rem Add compressed oops, if supported (64 bit VM), and not overriden
  111. echo "%JAVA_OPTS%" | findstr /I "\-XX:\-UseCompressedOops \-client" > nul
  112. if errorlevel == 1 (
  113. "%JAVA%" -XX:+UseCompressedOops -version > nul 2>&1
  114. if not errorlevel == 1 (
  115. set "JAVA_OPTS=-XX:+UseCompressedOops %JAVA_OPTS%"
  116. )
  117. )
  118. )
  119. if not "%PRESERVE_JAVA_OPTS%" == "true" (
  120. rem Add tiered compilation, if supported (64 bit VM), and not overriden
  121. echo "%JAVA_OPTS%" | findstr /I "\-XX:\-TieredCompilation \-client" > nul
  122. if errorlevel == 1 (
  123. "%JAVA%" -XX:+TieredCompilation -version > nul 2>&1
  124. if not errorlevel == 1 (
  125. set "JAVA_OPTS=-XX:+TieredCompilation %JAVA_OPTS%"
  126. )
  127. )
  128. )
  129. rem Find jboss-modules.jar, or we can't continue
  130. if exist "%JBOSS_HOME%\jboss-modules.jar" (
  131. set "RUNJAR=%JBOSS_HOME%\jboss-modules.jar"
  132. ) else (
  133. echo Could not locate "%JBOSS_HOME%\jboss-modules.jar".
  134. echo Please check that you are in the bin directory when running this script.
  135. goto END
  136. )
  137. rem Setup JBoss specific properties
  138. rem Setup the java endorsed dirs
  139. set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed
  140. rem Set default module root paths
  141. if "x%JBOSS_MODULEPATH%" == "x" (
  142. set "JBOSS_MODULEPATH=%JBOSS_HOME%\modules"
  143. )
  144. rem Set the standalone base dir
  145. if "x%JBOSS_BASE_DIR%" == "x" (
  146. set "JBOSS_BASE_DIR=%JBOSS_HOME%\standalone"
  147. )
  148. rem Set the standalone log dir
  149. if "x%JBOSS_LOG_DIR%" == "x" (
  150. set "JBOSS_LOG_DIR=%JBOSS_BASE_DIR%\log"
  151. )
  152. rem Set the standalone configuration dir
  153. if "x%JBOSS_CONFIG_DIR%" == "x" (
  154. set "JBOSS_CONFIG_DIR=%JBOSS_BASE_DIR%/configuration"
  155. )
  156. echo ===============================================================================
  157. echo.
  158. echo JBoss Bootstrap Environment
  159. echo.
  160. echo JBOSS_HOME: %JBOSS_HOME%
  161. echo.
  162. echo JAVA: %JAVA%
  163. echo.
  164. echo JAVA_OPTS: %JAVA_OPTS%
  165. echo.
  166. echo ===============================================================================
  167. echo.
  168. :RESTART
  169. "%JAVA%" %JAVA_OPTS% ^
  170. "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
  171. "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
  172. -jar "%JBOSS_HOME%\jboss-modules.jar" ^
  173. -mp "%JBOSS_MODULEPATH%" ^
  174. -jaxpmodule "javax.xml.jaxp-provider" ^
  175. org.jboss.as.standalone ^
  176. -Djboss.home.dir="%JBOSS_HOME%" ^
  177. %SERVER_OPTS%
  178. if ERRORLEVEL 10 goto RESTART
  179. :END
  180. if "x%NOPAUSE%" == "x" pause
  181. :END_NO_PAUSE