How to deploy a Java Linux Daemon with Java servcie Wrapper

Source: Internet
Author: User

Java Service Wrapper (http://wrapper.tanukisoftware.com/doc/english/integrate.html) is a tool that provides a set of Binar IES and scripts for different architectures and operating systems The Allow Java developers to run a Java application as A service daemon.

For this post I used a 64-bit CentOS PC as a server.

The source code of my test program is:

ImportJava.text.SimpleDateFormat;Importjava.util.Date;/** * @authorxingning OU*/ Public classSegmentservicemain { Public Static voidMain (string[] args) {SimpleDateFormat SDF=NewSimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");  while(true) {System.out.println (Sdf.format (NewDate ())); Try{Thread.Sleep (2000L); } Catch(interruptedexception e) {//TODO auto-generated Catch blockE.printstacktrace (); }        }    }}

1. Preparing the Environment:

mkdir -p/data/app/segment/mkdir -p/data/app/segment/mkdir -p/data/ app/segment/CP -R segment.jar/data/app/segment/bin/

2. Download and install Java Service Wrapper for Linux:

wget http://wrapper.tanukisoftware.com/download/3.5.25/wrapper-linux-x86-64-3.5.25.tar.gz 

3. Extract the package and copy the files needed:

 # tar -zxvf wrapper-linux-x86-64 - Span style= "color: #800080;" >3.5 . 25 . tar  .gz# CD wrapper -linux-x86-64 -3.5 . 25  #  CP  bin/wrapper/data/app/segment/bin/#  CP  src/bin/in /data/app/segment/bin/#  CP  Lib/*  /data/app/segment/bin/# CP conf/ wrapper.conf/data/app/segment/conf/ 

4. Rename the Servcie script and set correct permissions:

# cd/data/app/segment/bin/mv Sch.script.  in segment-chmod +x Segment-servcie

5. changeing some directive from the Config file (wrapper.conf)

6. Edit inti Script (Segment-service)

7. Run the application at boot time:

Ln -s/data/app/segment/bin/segment-service/etc/init.d/segment-235 Segment-service on

Reference:

http://opentodo.net/2013/03/deploying-java-unix-daemon-with-java-service-wrapper/

How to deploy a Java Linux Daemon with Java servcie Wrapper

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.