tomcat之启动文件catalina.bat详细解释

运行下面的程序,你就知道执行了什么语句

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

mode con cols=140 lines=100

echo .
echo .
echo .
echo						startup.bat运行过程解释 
echo .
echo		mode con cols=120 lines=100
echo		设置窗口大小
echo .
if "%OS%" == "Windows_NT" setlocal
echo		if "OS" == "Windows_NT" setlocal
echo		如果OS == %OS%,就开始设置Tomcat运行时所需要的环境,当运行结束后,所设置的环境变量失效	      
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 895392 2010-01-03 14:02:31Z kkolinko $
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
echo .
echo		set "CURRENT_DIR=%cd%"
echo		设置CURRENT_DIR环境变量为当前目录
if not "%CATALINA_HOME%" == "" goto gotHome
echo .
echo		if not "CATALINA_HOME" == "" goto gotHome
echo		如果没有设置CATALINA_HOME这个环境变量,则跳转到gothome,否则将设置这个环境变量
set "CATALINA_HOME=%CURRENT_DIR%"
echo .
echo		set "CATALINA_HOME=%CURRENT_DIR%"
echo		假设startup.bat运行的目录就是程序的主目录
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo .
echo		if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo		如果bin目录下存在catalina.bat这个文件,则假设成立,然后跳转到OKHome
cd ..
echo .
echo		cd ..
echo		否则假设失败,说明startup.bat在bin目录下,从新设置主目录环境变量
set "CATALINA_HOME=%cd%"
echo .
echo		set "CATALINA_HOME=%cd%"
echo		设置环境变量主目录
cd "%CURRENT_DIR%"
echo.
echo		cd "%CURRENT_DIR%"
echo		切换到当前目录
:gotHome
echo.
echo	:gotHome
echo		gothome标记,如果startup.bat在主目录下,则程序直接跳至这里
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo .
echo		if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo		如果bin目录下存在catalina.bat ,则跳到标志okHome处执行
echo		否则说明这个变量没有设置,
echo		The CATALINA_HOME environment variable is not defined correctly
echo		This environment variable is needed to run this program
goto end
echo .
echo	goto end
echo		:gotHome结束标志
:okHome
echo .
echo	:okHome
echo		okHome标志,当找到catalina.bat文件时,跳到这里。
set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"
echo .
echo		set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"
echo		设置可执行文件的环境变量为上面的内容

rem Check that target executable exists

if exist "%EXECUTABLE%" goto okExec
echo .
echo		if exist "%EXECUTABLE%" goto okExec
echo		检查这个catalina.bat是否存在,如果存在则跳转
echo		否则说明这个文件不存在
echo		Cannot find "%EXECUTABLE%"
echo 		This file is needed to run this program
goto end
echo .
echo	goto end
echo		:okHome结束标志
:okExec
echo .
echo	:okExec
echo		okExec标志,当可执行文件准备好后,执行这段内容
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
echo .
echo		set CMD_LINE_ARGS=
echo		将CMD_LINE_ARGS这个变量的值清空

:setArgs
echo .
echo	:setArgs
echo		设置参数
if ""%1""=="""" goto doneSetArgs
echo .
echo		if ""%1""=="""" goto doneSetArgs
echo		如果""%1""==""""进行跳转
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
echo .
echo		set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
echo		重新设置变量的值
shift
echo .
echo		shift
echo		命令移位
goto setArgs
echo .
echo		goto setArgs
echo		反复循环
:doneSetArgs
echo .
echo	:doneSetArgs
echo		设置好了参数


call "%EXECUTABLE%" start %CMD_LINE_ARGS%
echo .
echo		call "%EXECUTABLE%" start %CMD_LINE_ARGS%
echo		调用catalina.bat
:end
echo .
echo	:end
echo		结束标志

你可能感兴趣的:(tomcat之启动文件catalina.bat详细解释)