Tomcat start batch processing -- startup. bat, tomcatstartup. bat
From the file name, we can see that this is a start batch processing. The main function of this batch processing is to find another batch processing catalina. bat and execute catalina. bat.
At the beginning, use if "% OS %" = "Windows_NT" setlocal to determine whether the system is Windows_NT. if yes, use the setlocal command, this command indicates that all subsequent changes to the environment variables are limited to the batch files. To restore the original settings, You can execute the endlocal command, if not explicitly executed, the endlocal command is automatically implicitly executed at the end of the batch processing.
The following script sets the CATALINA_HOME environment variable, and finally determines the catalina. bat path. 3-2-1-1 clearly expresses the logic for determining the value of the CATALINA_HOME variable. ① If CATALINA_HOME is set for the system variable, directly use the value set for the system variable as the tomcat installation directory. ② If the system variable CATALINA_HOME is not set, the current directory of the batch processing or command line is used as CATALINA_HOME. If % CATALINA_HOME % \ bin \ catalina. if bat exists, the current directory of the batch processing or command line is CATALINA_HOME. ③ Assume % CATALINA_HOME % \ bin \ catalina. if bat does not exist, use the upper-level directory of the current directory as CATALINA_HOME, and then judge % CATALINA_HOME % \ bin \ catalina. if bat exists, the upper-level directory of the current directory is CATALINA_HOME. Otherwise, the system prompts that the CATALINA_HOME environment variable cannot be found.
For situations ② and ③, it may be more likely to have doubts. ② It is mainly used for command line execution. The current directory of the command line is the tomcat installation directory, and bin \ startup. bat is executed. ③ It may be a command line execution or a double-click batch execution. The command line execution is to switch the current directory to the tomcat installation directory \ bin, the current directories of the two execution methods are the same.
**************************************** **************************************** ************
Set "CURRENT_DIR = % cd %"
If not "% CATALINA_HOME %" = "" goto gotHome
Set "CATALINA_HOME = % CURRENT_DIR %"
If exist "% CATALINA_HOME % \ bin \ catalina. bat" goto okHome
Cd ..
Set "CATALINA_HOME = % cd %"
Cd "% CURRENT_DIR %"
: GotHome
If exist "% CATALINA_HOME % \ bin \ catalina. bat" goto okHome
Goto end
: OkHome
Set "EXECUTABLE = % CATALINA_HOME % \ bin \ catalina. bat"
If exist "% EXECUTABLE %" goto okExec
Goto end
: OkExec
**************************************** **************************************** ************
Figure 3-2-1-1
The value of CATALINA_HOME has been determined, that is, catalina. bat. The next step is to accept parameters. Some command parameters are often included at startup. startup. bat collects parameters through the following program.
**************************************** **************************************** ************
Set pai_line_args =
: SetArgs
If "% 1" "=" goto doneSetArgs
Set pai_line_args = % pai_line_args % 1 // set the parameter to a row and connect it
Shift
Goto setArgs
: DoneSetArgs
**************************************** **************************************** ************
First, set the CMD_LINE_ARGS environment variable to null. First, judge whether the first parameter is null. If it is null, it indicates that no parameter exists. directly jump to the doneSetArgs position. If the first parameter is not empty, assign the first parameter to pai_line_args, the shift command moves the parameter one by one. % 1 represents the original second parameter, and then jumps to the setArgs position. In this case, the second parameter is determined, if it is not empty, append the parameter to pai_line_args. By analogy, parameters are moved forward one by one until % 1 is null, indicating that all parameters have been collected.
Call "% EXECUTABLE %" start % CMD_LINE_ARGS %. This command uses all the collected parameters pai_line_args as parameters and calls catalina. bat for batch processing.
How does batchcompute bat check whether the DB2 service is started? If the service is started, start the startupbat script in tomcat
Not clear
If you have deployed a program, start tomcat from myeclipse every time? Start tomcat directly at startupbat, but the program is not executed.
Package the project to the tomcat webapps directory.