Use Java Service Wrapper to configure Tomcat applications under Linux

Source: Internet
Author: User

Objective

Java Service Wrapper is a product of tanuki software that can register a Java application as a Windows or Linux service, enable it to boot with the system, and monitor the state of the Java application so that it starts automatically when abnormal conditions Refer to the official documentation overview of Wrapper features, this document describes the author's practice of using Java Serivice Wrapper to configure Tomcat applications under the guidance of the official documentation in the Linux environment.

Premise
    • Suse Linux 64-bit
    • Java 8 Download
    • Tomcat 8 Download
    • Java Service Wrapper Linux 64bit Download
Install deploy Java install to/usr/local/java8/specific steps for a slightly tomcat installation to/usr/local/tomcat/specific steps to make a Java web App into a war package, drag it to tomcat/webapps/ Specific steps to extract the Java Service Wrapper compressed package to/usr/local/wrapper/, start installing wrapper file: Bin directory

Copy the following files to the Tomcat/bin directory:

/usr/local/wrapper/bin/wrapper/usr/local/wrapper/src/bin/sh. Script. inch

The script file sh.script.in renamed to your app name, such as ABC.

Open ABC with the editor, find App_name, change the value to match the file name, and change the value of App_long_name to apply the long name.

App_name="ABC"app_long_name="ABC application Server" 

Save close file, Grant execute permission to script file ABC

Lib Directory

Copy the following files to the Tomcat/lib directory:

/usr/local/wrapper/lib/libwrapper.so/usr/local/wrapper/lib/wrapper.jar
Conf Directory

Copy wrapper.conf to tomcat/conf directory, edit wrapper.conf file:

//Configure the Java path, depending on the environment configuration, you can use an absolute path, or you can work with environment variablesSet. java_home=/usr/local/java8/set. Catalina_home=/usr/local/Tomcatset. Catalina_base=/usr/local/Tomcatwrapper.java.command=/usr/local/java8/bin/Java//JVM parameters. Copy the parameters that are configured when the app starts normally. Specific steps://1. Command line launch app//2. Use Ps–ef | grep tomcat to find the application process//3. Copy the parameters of the process and configure the parameters starting with-D to the followingWrapper.java.additional.1=-djava.util.logging.config.file=%catalina_home%/conf/logging.propertieswrapper.java.additional.2=-djava.util.logging.manager=org.apache.juli.ClassLoaderLogManagerwrapper.java.additional.3=-djava.endorsed.dirs=%catalina_home%/common/endorsedwrapper.java.additional.4=-dcatalina.base=%catalina_base%wrapper.java.additional.5=-dcatalina.home=%catalina_home%wrapper.java.additional.6=-djava.io.tmpdir=%catalina_base%/Temp//The class path. The same way you get the JVM parameters, configure the classpath to the followingWrapper.java.classpath.1=%catalina_home%/bin/Bootstrap.jarwrapper.java.classpath.2=%catalina_home%/bin/tomcat-Juli.jarwrapper.java.classpath.3=%catalina_home%/lib/Wrapper.jar//Lib path. Wrapper.java.library.path.1=%catalina_home%/Lib//Wrapper integrates the main class. There are 4 ways to integrate, for Tomcat to start using a class,//The Wrapperstartstopapp class is used to stop using another classwrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperStartStopApp//Tomcat application parameters, without modificationWrapper.app.parameter.1=Org.apache.catalina.startup.Bootstrapwrapper.app.parameter.2=1Wrapper.app.parameter.3=Startwrapper.app.parameter.4=Org.apache.catalina.startup.Bootstrapwrapper.app.parameter.5=TRUEwrapper.app.parameter.6=1Wrapper.app.parameter.7=stop
Installation Services

Enter the/usr/local/tomcat/bin/directory, modify the script file ABC, set up with system boot

// set up service to boot with system Use_upstart=True

Save exit, execute with root permission

sudo Install

App will register as upstart service

Notice: Only valid after wrapper version 3.4.0

Test

Execute command

Service Start | Stop | Restart | Status

After the tomcat/logs/directory to view the Wrapper.log, no exception is the success.

Restart the machine, log in to see if the process has ABC running, to prove that the system started normally, or access the Java Web application, to prove that the application started normally.

Use Java Service Wrapper to configure Tomcat applications under Linux

Related Article

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.