这个东西我调查了好几天,累啊不过还是没有搞得很清楚,不过也有点收获了
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中提示)