Tomcat start batch processing -- startup. bat

Source: Internet
Author: User


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.



Tomcat start batch processing -- startup. bat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.