這個東西我調查了好幾天,累啊不過還是沒有搞得很清楚,不過也有點收獲了
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中提示)