Deploying Java Unix Daemon with Java Service Wrapper

本文详细介绍如何使用Java Service Wrapper在Linux环境下部署Java应用为守护进程,包括环境准备、安装配置Wrapper及启动脚本编辑等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


- Preparing the environment:

1
2
3
4
# mkdir -p /usr/local/queuesApp/bin/
# mkdir /usr/local/queuesApp/conf
# mkdir /usr/local/queuesApp/logs
# cp -r rabbitmqConsumer.jar lib/ /usr/local/queuesApp/bin/

- Preparing the environment:

1
2
3
4
# mkdir -p /usr/local/queuesApp/bin/
# mkdir /usr/local/queuesApp/conf
# mkdir /usr/local/queuesApp/logs
# cp -r rabbitmqConsumer.jar lib/ /usr/local/queuesApp/bin/

- Download and install java service wrapper for Linux:

- 32 bits systems:

- 64 bits systems:

- Extract the package and copy the files needed:

1
2
3
4
5
6
# tar -xzvf wrapper-linux-x86-*-3.5.17.tar.gz
  # cd wrapper-linux-x86-*-3.5.17/
  # cp bin/wrapper /usr/local/queuesApp/bin/
  # cp src/bin/sh.script.in /usr/local/queuesApp/bin/
  # cp lib/* /usr/local/queuesApp/bin/
  # cp conf/wrapper.conf /usr/local/queuesApp/conf/

- Rename the service script and set correct permissions:

1
2
3
# cd /usr/local/queuesApp/bin/
  # mv sh.script.in consumer-daemon
  # chmod +x consumer-daemon

- Changing some directive from the config file for our application:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# cd /usr/local/queuesApp/conf/
  # vi wrapper.conf
 
#********************************************************************
  # Wrapper Java Properties
  #********************************************************************
  # Java Application
  # Locate the java binary on the system PATH:
  wrapper.java. command =java
 
# Java Main class. This class must implement the WrapperListener interface
  # or guarantee that the WrapperManager class is initialized. Helper
  # classes are provided to do this for you. See the Integration section
  # of the documentation for details.
  wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp
 
# Java Classpath (include wrapper.jar) Add class path elements as
  # needed starting from 1
  wrapper.java.classpath.1=.. /bin/wrapper .jar
 
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
  wrapper.java.library.path.1=.. /bin
 
# Application parameters. Add parameters as needed starting from 1
  wrapper.app.parameter.1=.. /bin/rabbitmqConsumer .jar


  • wrapper.java.command : It’s the path for the java binary, by default in Linux it’s found in the PATH.
  • wrapper.java.mainclass: The main class to load our program, it may be different depending of the integration method used.
  • wrapper.java.classpath.1 : the location for the wrapper jar.
  • wrapper.java.library.path.1 : The path for the wrapper binary.
  • wrapper.app.parameter.1 : The jar package for our program.

- Edit init script:

1
2
3
4
# vi /usr/local/queuesApp/bin/consumer-daemon
 
APP_NAME= "consumer-daemon"
  APP_LONG_NAME= "Consumer Java Daemon for RabbitMQ"

- Run the aplication at boot time:

1
2
# ln -s /usr/local/queuesApp/bin/consumer-daemon /etc/init.d/consumer-daemon
# chkconfig --levels 235 consumer-daemon on

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值