Introduction and use of Java Service Wrapper

Source: Internet
Author: User

This article turns from https://www.cnblogs.com/zcy_soft/p/3738947.html, writes very well, treasures a bit

1. What does the wrapper mean?

Wrapper is understood here as " packaging ".

2. What is the role of Java service wrapper?

  In the actual development process, many modules need to run independently, they will not be published as a web, the traditional approach is to compress it into a jar package run independently, this form is easy and easier to maintain, but once the server restarts or an exception, the program is often unable to repair or restart itself. The traditional way to fix a server restart is to write a shell script that runs with the server, but this is only a symptom, so what do we want to do to find a "permanent solution"? Java Service wrapper easily solves this problem by wrapping Java programs as system services.

The Java Service wrapper to solve these problems for us easily and simply. "Java Service Wrapper": As the name implies, it is used to package our Java programs into system services so that they can run automatically as the system runs. Of course, the functionality of Java Service Wrapper ( hereinafter referredto as Wrapper) is definitely not just here.

4. Wrapper Download and use

https://wrapper.tanukisoftware.com/doc/english/download.jsp

Through the download page we can see that wrapper almost support all the system environment, indicating that wrapper in this area is still very important, the latest version is 3.5.20, we choose to download the Linux x86 version, extract the directory composition

As shown in the following:

For a more intuitive understanding of wrapper's directory and file structure, you can list all of the wrapper's file trees through the "tree" command, and the CMD console to enter commands:

The following are some of the advantages of the official wrapper:

(1) The use of our products does not require any additional code to be added to your program.

(2) Automatically responds to pre-customized policies when problems occur with your program or JVM.

(3) When there is a problem will be timely notification.

(4) The perfect logging function can provide better support for you.

(5) on different systems you can specify a standard process for the same process, i.e. the same program can run on different systems without modification.

(6) You can install your app as a service or daemon for Windows or Unix .

Seeing wrapper has so many benefits, we'll learn more about wrapper by Wrapper's own sample program:

1. Create the Service working directory, the operating system for Linux, directory structure for Usr/local/wrapper, for example, according to the above directory structure, under which create "Bin", "conf", "Lib", "logs" The four folders of the same name.

2. Copy the configuration and program files to the appropriate directory (that is, the file labeled ★ above);

(1) The wrapper file under the Bin directory is copied to Usr/local/wrapper/bin.

(2) The sh.script.in file under the Src\bin directory is copied to Usr/local/wrapper/bin, and the. In suffix is removed and the name is modified to Javaservice.script.

(3) The wrapper.conf file under the Conf directory is copied to usr/local/wrapper/conf.

(4) Wrapper.jar and libwrapper.so files under the Lib directory are copied to usr/local/wrapper/lib.

Note: The above is the formal environment required for the configuration of the file, here we need to run wrapper bring the demo program, so we need to copy the Demoapp,demoapp.conf,wrapperdemo.jar three files to the appropriate directory.

3. Go to the Bin directory and execute the following command:

Next, you'll see a lot of hints that will eventually show the following page:

This page appears to prove that your program has been running successfully, congratulations!

If the startup fails, we can view the logs log contents as follows:

  

From the log content can view the program and the operation status of the service,wrapper log In this format: type | owner | time | specific content

The log content shows that our Linux system does not have a graphical interface or no graphics card at all.

Note: It needs to be explained here that the wrapper run requires the Java Runtime Environment support first, so please make sure that Java is installed before using wrapper.

Let's try a way to invoke the service without arguments, such as:

The tips for both are the same:

  The original wrapper provides a number of options for parameters, such as: Start for start, stop for stop. The following is a detailed explanation of the parameters:

We also found that the prompt for running the wrapper command separately differs from the previous two, as follows:

  because wrapper is the main program that wrapper runs and is also the core, he cannot run it alone and needs to be called through the sh.script.in shell script in Src/bin, which we'll talk about later .

Run wrapper you can add parameters as indicated above, such as:./wrapper-c wrapper.properties

Above is an overall understanding of wrapper, hope this article can help you get started faster and use wrapper, after a few articles will be detailed wrapper configuration and customize their own applications.

Introduction and use of Java Service wrapper (GO)

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.