PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/lucee/tomcat8/tomcat/bin/catalina.bat

http://github.com/utdream/CFML-Installers
Batch | 332 lines | 300 code | 32 blank | 0 comment | 79 complexity | f732cca460eb858f3c2dfff28244f099 MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0, BSD-3-Clause-No-Nuclear-License-2014, Unlicense
  1. @echo off
  2. rem Licensed to the Apache Software Foundation (ASF) under one or more
  3. rem contributor license agreements. See the NOTICE file distributed with
  4. rem this work for additional information regarding copyright ownership.
  5. rem The ASF licenses this file to You under the Apache License, Version 2.0
  6. rem (the "License"); you may not use this file except in compliance with
  7. rem the License. You may obtain a copy of the License at
  8. rem
  9. rem http://www.apache.org/licenses/LICENSE-2.0
  10. rem
  11. rem Unless required by applicable law or agreed to in writing, software
  12. rem distributed under the License is distributed on an "AS IS" BASIS,
  13. rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. rem See the License for the specific language governing permissions and
  15. rem limitations under the License.
  16. rem ---------------------------------------------------------------------------
  17. rem Start/Stop Script for the CATALINA Server
  18. rem
  19. rem Environment Variable Prerequisites
  20. rem
  21. rem Do not set the variables in this script. Instead put them into a script
  22. rem setenv.bat in CATALINA_BASE/bin to keep your customizations separate.
  23. rem
  24. rem CATALINA_HOME May point at your Catalina "build" directory.
  25. rem
  26. rem CATALINA_BASE (Optional) Base directory for resolving dynamic portions
  27. rem of a Catalina installation. If not present, resolves to
  28. rem the same directory that CATALINA_HOME points to.
  29. rem
  30. rem CATALINA_OPTS (Optional) Java runtime options used when the "start",
  31. rem "run" or "debug" command is executed.
  32. rem Include here and not in JAVA_OPTS all options, that should
  33. rem only be used by Tomcat itself, not by the stop process,
  34. rem the version command etc.
  35. rem Examples are heap size, GC logging, JMX ports etc.
  36. rem
  37. rem CATALINA_TMPDIR (Optional) Directory path location of temporary directory
  38. rem the JVM should use (java.io.tmpdir). Defaults to
  39. rem %CATALINA_BASE%\temp.
  40. rem
  41. rem JAVA_HOME Must point at your Java Development Kit installation.
  42. rem Required to run the with the "debug" argument.
  43. rem
  44. rem JRE_HOME Must point at your Java Runtime installation.
  45. rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
  46. rem are both set, JRE_HOME is used.
  47. rem
  48. rem JAVA_OPTS (Optional) Java runtime options used when any command
  49. rem is executed.
  50. rem Include here and not in CATALINA_OPTS all options, that
  51. rem should be used by Tomcat and also by the stop process,
  52. rem the version command etc.
  53. rem Most options should go into CATALINA_OPTS.
  54. rem
  55. rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories
  56. rem containing some jars in order to allow replacement of APIs
  57. rem created outside of the JCP (i.e. DOM and SAX from W3C).
  58. rem It can also be used to update the XML parser implementation.
  59. rem Defaults to $CATALINA_HOME/endorsed.
  60. rem
  61. rem JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start"
  62. rem command is executed. The default is "dt_socket".
  63. rem
  64. rem JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start"
  65. rem command is executed. The default is localhost:8000.
  66. rem
  67. rem JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start"
  68. rem command is executed. Specifies whether JVM should suspend
  69. rem execution immediately after startup. Default is "n".
  70. rem
  71. rem JPDA_OPTS (Optional) Java runtime options used when the "jpda start"
  72. rem command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,
  73. rem and JPDA_SUSPEND are ignored. Thus, all required jpda
  74. rem options MUST be specified. The default is:
  75. rem
  76. rem -agentlib:jdwp=transport=%JPDA_TRANSPORT%,
  77. rem address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%
  78. rem
  79. rem LOGGING_CONFIG (Optional) Override Tomcat's logging config file
  80. rem Example (all one line)
  81. rem set LOGGING_CONFIG="-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties"
  82. rem
  83. rem LOGGING_MANAGER (Optional) Override Tomcat's logging manager
  84. rem Example (all one line)
  85. rem set LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
  86. rem
  87. rem TITLE (Optional) Specify the title of Tomcat window. The default
  88. rem TITLE is Tomcat if it's not specified.
  89. rem Example (all one line)
  90. rem set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%]
  91. rem ---------------------------------------------------------------------------
  92. setlocal
  93. rem Suppress Terminate batch job on CTRL+C
  94. if not ""%1"" == ""run"" goto mainEntry
  95. if "%TEMP%" == "" goto mainEntry
  96. if exist "%TEMP%\%~nx0.run" goto mainEntry
  97. echo Y>"%TEMP%\%~nx0.run"
  98. if not exist "%TEMP%\%~nx0.run" goto mainEntry
  99. echo Y>"%TEMP%\%~nx0.Y"
  100. call "%~f0" %* <"%TEMP%\%~nx0.Y"
  101. rem Use provided errorlevel
  102. set RETVAL=%ERRORLEVEL%
  103. del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1
  104. exit /B %RETVAL%
  105. :mainEntry
  106. del /Q "%TEMP%\%~nx0.run" >NUL 2>&1
  107. rem Guess CATALINA_HOME if not defined
  108. set "CURRENT_DIR=%cd%"
  109. if not "%CATALINA_HOME%" == "" goto gotHome
  110. set "CATALINA_HOME=%CURRENT_DIR%"
  111. if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  112. cd ..
  113. set "CATALINA_HOME=%cd%"
  114. cd "%CURRENT_DIR%"
  115. :gotHome
  116. if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  117. echo The CATALINA_HOME environment variable is not defined correctly
  118. echo This environment variable is needed to run this program
  119. goto end
  120. :okHome
  121. rem Copy CATALINA_BASE from CATALINA_HOME if not defined
  122. if not "%CATALINA_BASE%" == "" goto gotBase
  123. set "CATALINA_BASE=%CATALINA_HOME%"
  124. :gotBase
  125. rem Ensure that neither CATALINA_HOME nor CATALINA_BASE contains a semi-colon
  126. rem as this is used as the separator in the classpath and Java provides no
  127. rem mechanism for escaping if the same character appears in the path. Check this
  128. rem by replacing all occurrences of ';' with '' and checking that neither
  129. rem CATALINA_HOME nor CATALINA_BASE have changed
  130. if "%CATALINA_HOME%" == "%CATALINA_HOME:;=%" goto homeNoSemicolon
  131. echo Using CATALINA_HOME: "%CATALINA_HOME%"
  132. echo Unable to start as CATALINA_HOME contains a semicolon (;) character
  133. goto end
  134. :homeNoSemicolon
  135. if "%CATALINA_BASE%" == "%CATALINA_BASE:;=%" goto baseNoSemicolon
  136. echo Using CATALINA_BASE: "%CATALINA_BASE%"
  137. echo Unable to start as CATALINA_BASE contains a semicolon (;) character
  138. goto end
  139. :baseNoSemicolon
  140. rem Ensure that any user defined CLASSPATH variables are not used on startup,
  141. rem but allow them to be specified in setenv.bat, in rare case when it is needed.
  142. set CLASSPATH=
  143. rem Get standard environment variables
  144. if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome
  145. call "%CATALINA_BASE%\bin\setenv.bat"
  146. goto setenvDone
  147. :checkSetenvHome
  148. if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
  149. :setenvDone
  150. rem Get standard Java environment variables
  151. if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath
  152. echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat"
  153. echo This file is needed to run this program
  154. goto end
  155. :okSetclasspath
  156. call "%CATALINA_HOME%\bin\setclasspath.bat" %1
  157. if errorlevel 1 goto end
  158. rem Add on extra jar file to CLASSPATH
  159. rem Note that there are no quotes as we do not want to introduce random
  160. rem quotes into the CLASSPATH
  161. if "%CLASSPATH%" == "" goto emptyClasspath
  162. set "CLASSPATH=%CLASSPATH%;"
  163. :emptyClasspath
  164. set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar"
  165. if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir
  166. set "CATALINA_TMPDIR=%CATALINA_BASE%\temp"
  167. :gotTmpdir
  168. rem Add tomcat-juli.jar to classpath
  169. rem tomcat-juli.jar can be over-ridden per instance
  170. if not exist "%CATALINA_BASE%\bin\tomcat-juli.jar" goto juliClasspathHome
  171. set "CLASSPATH=%CLASSPATH%;%CATALINA_BASE%\bin\tomcat-juli.jar"
  172. goto juliClasspathDone
  173. :juliClasspathHome
  174. set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar"
  175. :juliClasspathDone
  176. if not "%LOGGING_CONFIG%" == "" goto noJuliConfig
  177. set LOGGING_CONFIG=-Dnop
  178. if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig
  179. set LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"
  180. :noJuliConfig
  181. set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"
  182. if not "%LOGGING_MANAGER%" == "" goto noJuliManager
  183. set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  184. :noJuliManager
  185. set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"
  186. rem ----- Execute The Requested Command ---------------------------------------
  187. echo Using CATALINA_BASE: "%CATALINA_BASE%"
  188. echo Using CATALINA_HOME: "%CATALINA_HOME%"
  189. echo Using CATALINA_TMPDIR: "%CATALINA_TMPDIR%"
  190. if ""%1"" == ""debug"" goto use_jdk
  191. echo Using JRE_HOME: "%JRE_HOME%"
  192. goto java_dir_displayed
  193. :use_jdk
  194. echo Using JAVA_HOME: "%JAVA_HOME%"
  195. :java_dir_displayed
  196. echo Using CLASSPATH: "%CLASSPATH%"
  197. set _EXECJAVA=%_RUNJAVA%
  198. set MAINCLASS=org.apache.catalina.startup.Bootstrap
  199. set ACTION=start
  200. set SECURITY_POLICY_FILE=
  201. set DEBUG_OPTS=
  202. set JPDA=
  203. if not ""%1"" == ""jpda"" goto noJpda
  204. set JPDA=jpda
  205. if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport
  206. set JPDA_TRANSPORT=dt_socket
  207. :gotJpdaTransport
  208. if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress
  209. set JPDA_ADDRESS=localhost:8000
  210. :gotJpdaAddress
  211. if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend
  212. set JPDA_SUSPEND=n
  213. :gotJpdaSuspend
  214. if not "%JPDA_OPTS%" == "" goto gotJpdaOpts
  215. set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%
  216. :gotJpdaOpts
  217. shift
  218. :noJpda
  219. if ""%1"" == ""debug"" goto doDebug
  220. if ""%1"" == ""run"" goto doRun
  221. if ""%1"" == ""start"" goto doStart
  222. if ""%1"" == ""stop"" goto doStop
  223. if ""%1"" == ""configtest"" goto doConfigTest
  224. if ""%1"" == ""version"" goto doVersion
  225. echo Usage: catalina ( commands ... )
  226. echo commands:
  227. echo debug Start Catalina in a debugger
  228. echo debug -security Debug Catalina with a security manager
  229. echo jpda start Start Catalina under JPDA debugger
  230. echo run Start Catalina in the current window
  231. echo run -security Start in the current window with security manager
  232. echo start Start Catalina in a separate window
  233. echo start -security Start in a separate window with security manager
  234. echo stop Stop Catalina
  235. echo configtest Run a basic syntax check on server.xml
  236. echo version What version of tomcat are you running?
  237. goto end
  238. :doDebug
  239. shift
  240. set _EXECJAVA=%_RUNJDB%
  241. set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java"
  242. if not ""%1"" == ""-security"" goto execCmd
  243. shift
  244. echo Using Security Manager
  245. set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy"
  246. goto execCmd
  247. :doRun
  248. shift
  249. if not ""%1"" == ""-security"" goto execCmd
  250. shift
  251. echo Using Security Manager
  252. set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy"
  253. goto execCmd
  254. :doStart
  255. shift
  256. if "%TITLE%" == "" set TITLE=Tomcat
  257. set _EXECJAVA=start "%TITLE%" %_RUNJAVA%
  258. if not ""%1"" == ""-security"" goto execCmd
  259. shift
  260. echo Using Security Manager
  261. set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy"
  262. goto execCmd
  263. :doStop
  264. shift
  265. set ACTION=stop
  266. set CATALINA_OPTS=
  267. goto execCmd
  268. :doConfigTest
  269. shift
  270. set ACTION=configtest
  271. set CATALINA_OPTS=
  272. goto execCmd
  273. :doVersion
  274. %_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo
  275. goto end
  276. :execCmd
  277. rem Get remaining unshifted command line arguments and save them in the
  278. set CMD_LINE_ARGS=
  279. :setArgs
  280. if ""%1""=="""" goto doneSetArgs
  281. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  282. shift
  283. goto setArgs
  284. :doneSetArgs
  285. rem Execute Java with the applicable properties
  286. if not "%JPDA%" == "" goto doJpda
  287. if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
  288. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  289. goto end
  290. :doSecurity
  291. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  292. goto end
  293. :doJpda
  294. if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
  295. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  296. goto end
  297. :doSecurityJpda
  298. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  299. goto end
  300. :end