java service wrapper 在linux下实现jar用服务启动

 这个东西我调查了好几天,累啊不过还是没有搞得很清楚,不过也有点收获了(linux)

windows的网络上很多 ,不多说了,不过conf/wrapper.conf这个文件差不多的


安装JDK,。比如你的projecct安装在/usr/local/myP中。

使用命令wget Java Service Wrapper(目前版本wrapper-linux-x86-32-3.2.3,官网:http://wrapper.tanukisoftware.org), 用命令tar -zxvc wrapper-linux-x86-32-3.2.3.tar.gz ,得到目wrapper-linux-x86-32-3.2.3,使用ln -s wrapper-linux-x86-32-3.2.3 wrapper wrapper-linux-x86-32-3.2.3 建一个名称wrapper的快捷方式。

复制wrapper/src/bin/sh.script.in/usr/local/myP/bin,重命名tomcat

复制wrapper/src/conf/wrapper.conf.in//usr/local/myP/conf,重命名wrapper.conf

复制wrapper/src/lib/lib下的所有3个文件到/usr/local/myP/lib

复制wrapper/bin下的wrapper文件到/usr/local/myP/bin

修改/usr/local/myP/bin/tomcat文件

APP_NAME="Servername  "

APP_LONG_NAME="Servername  Server"

WRAPPER_CMD="./wrapper"

WRAPPER_CONF="../conf/wrapper.conf"


#********************************************************************

# Wrapper Properties

#********************************************************************

# Java Application

wrapper.java.command=%JAVA_HOME%/bin/java       //系统需要设定JAVA_HOME


# 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.WrapperSimpleApp


# Java Classpath (include wrapper.jar)  Add class path elements as

#  needed starting from 1

wrapper.java.classpath.1=../lib/wrapper.jar

wrapper.java.classpath.2=../lib/wrappertest.jar

wrapper.java.classpath.3=../bin/log4j-1.2.8.jar

wrapper.java.classpath.4=../bin/.

wrapper.java.classpath.5=../bin/myP.jar   //需要加载的包,这个包是你需要运行的jar包,是需要加载的


# Java Library Path (location of Wrapper.DLL or libwrapper.so)

wrapper.java.library.path.1=../lib


# Java Additional Parameters

#wrapper.java.additional.1=


# Initial Java Heap Size (in MB)

#wrapper.java.initmemory=3


# Maximum Java Heap Size (in MB)

#wrapper.java.maxmemory=64


# Application parameters.  Add parameters as needed starting from 1

wrapper.app.parameter.1=com.client.ProcessMain   //是需要执行的mian函数(myP.jar )


#********************************************************************

# Wrapper Logging Properties

#********************************************************************

# Format of output for the console.  (See docs for formats)

wrapper.console.format=PM


# Log Level for console output.  (See docs for log levels)

wrapper.console.loglevel=INFO


# Log file to use for wrapper output logging.

wrapper.logfile=../logs/wrapper.log


# Format of output for the log file.  (See docs for formats)

wrapper.logfile.format=LPTM


# Log Level for log file output.  (See docs for log levels)

wrapper.logfile.loglevel=INFO


# Maximum size that the log file will be allowed to grow to before

#  the log is rolled. Size is specified in bytes.  The default value

#  of 0, disables log rolling.  May abbreviate with the 'k' (kb) or

#  'm' (mb) suffix.  For example: 10m = 10 megabytes.

wrapper.logfile.maxsize=0


# Maximum number of rolled log files which will be allowed before old

#  files are deleted.  The default value of 0 implies no limit.

wrapper.logfile.maxfiles=0


# Log Level for sys/event log output.  (See docs for log levels)

wrapper.syslog.loglevel=NONE


#********************************************************************

# Wrapper Windows Properties

#********************************************************************

# Title to use when running as a console

wrapper.console.title=WebAPFWonline Service     //看英文 名字


#********************************************************************

# Wrapper Windows NT/2000/XP Service Properties

#********************************************************************

# WARNING - Do not modify any of these properties when an application

#  using this configuration file has been installed as a service.

#  Please uninstall the service before modifying this section.  The

#  service can then be reinstalled.


# Name of the service

wrapper.ntservice.name=Servername  //服务名


# Display name of the service

wrapper.ntservice.displayname=Servername Service  //显示的服务名


# Description of the service

wrapper.ntservice.description=Servername Service  //服务描述


# Service dependencies.  Add dependencies as needed starting from 1

wrapper.ntservice.dependency.1=


# Mode in which the service is installed.  AUTO_START or DEMAND_START

wrapper.ntservice.starttype=AUTO_START     //自动启动


# Allow the service to interact with the desktop.

wrapper.ntservice.interactive=false


把ln   -s   /usr/asc/Servername      /etc/init.d    
注意
(
/usr/asc/Servername一定要全路径,否则是一个复制的是个无效文件)

     /etc/init.d/Appserver     start   这样就可以了 测试了

注意:

如果我把wrapper.java.command=%JAVA_HOME%/bin/java        

写成系统jdk的全路径  /usr/java/jdk/bin/java

那么         /usr/asc路径下       运行       ./Appserver       start       是可以的

其他路径下       运行       service       Appserver       start       也可以运行.  

估计service这个命令   不给他指定JAVA_HOME   可能读不到JAVA_HOME了

这个我也不太清楚

service       Appserver       start 会出现
Unable   to   locate   any   of   the   following   binaries:
    /etc/rc.d/init.d/./wrapper-linux-x86-32
    /etc/rc.d/init.d/./wrapper-linux-x86-64
    /etc/rc.d/init.d/./wrapper  错误

或者无法启动jvm
(service       Appserver      console中提示)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值