最近幫客戶系統製作安裝光碟時,在安裝Tomcat發現如果不是使用Tomcat官網下載的exe安裝檔案,透過Tomcat\bin 下的service 進行服務安裝時,裝好的服務預設啟動模式為手動
找了一下資料,發現有二種解法
1.直接從service.bat 下手,請用編輯器打開 找尋 「 :installed 」在這執行腳本中的
“%EXECUTABLE%” //US//%SERVICE_NAME% ++JvmOptions “-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties” –JvmMs 256 –JvmMx 512
加上 –Startup=auto ,結果如下:
“%EXECUTABLE%” //US//%SERVICE_NAME% ++JvmOptions “-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties” –JvmMs 256 –JvmMx 512 –Startup=auto
這樣執行service install tomcat5 後就預設啟動模式為自動啦
2.第二個方法,是透過window的指令下手,請執行
sc config service_name start=auto
這樣也行,所以可以把這指令寫在安裝步驟也可以達到預期效果
以上執行在搭配Tomcat 5.5 測試過~是ok的!!
如果要調整安裝在Windows 上Tomcat服務的參數可以在console mode執行以下指令即可進行更改啟動參數
C:\> tomcat6 //US//Tomcat6 –Description=”Apache Tomcat Server – http://tomcat.apache.org/ ” \
C:\> –Startup=auto –Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar \
C:\> –JvmMx=512
重點在於使用 //US// (Update service parameters) 指令進行更新參數作業,可使用詳細參數如下:
ParameterName |
Default |
Description |
–Description |
|
Service name description (maximum 1024 characters) |
–DisplayName |
ServiceName |
Service display name |
–Install |
procrun.exe //RS//ServiceName |
Install image |
–Startup |
manual |
Service startup mode can be either auto or manual |
–DependsOn |
|
List of services that this service depend on. Dependent services are separated using either # or ; characters |
–Environment |
|
List of environment variables that will be provided to the service in the form key=value. They are separated using either # or ; characters |
–User |
|
User account used for running executable. It is used only for StartMode java or exe and enables running applications as service under account without LogonAsService privilege. |
–Password |
|
Password for user account set by –User parameter |
–JavaHome |
JAVA_HOME |
Set a different JAVA_HOME then defined by JAVA_HOME environment variable |
–Jvm |
auto |
Use either auto or specify the full path to the jvm.dll. You can use the environment variable expansion here. |
–JvmOptions |
-Xrs |
List of options in the form of -D or -X that will be passed to the JVM. The options are separated using either # or ; characters. |
–Classpath |
|
Set the Java classpath |
–JvmMs |
|
Initial memory pool size in MB |
–JvmMx |
|
Maximum memory pool size in MB |
–JvmSs |
|
Thread stack size in KB |
–StartImage |
|
Executable that will be run. |
–StartPath |
|
Working path for the start image executable. |
–StartClass |
|
Class that will be used for startup. |
–StartParams |
|
List of parameters that will be passed to either StartImage or StartClass. Parameters are separated using either # or ; character. |
–StartMethod |
Main |
Method name if differs then main |
–StartMode |
executable |
Can one of jvm java or exe |
–StopImage |
|
Executable that will be run on Stop service signal. |
–StopPath |
|
Working path for the stop image executable. |
–StopClass |
|
Class that will be used on Stop service signal. |
–StopParams |
|
List of parameters that will be passed to either StopImage or StopClass. Parameters are separated using either # or ; character. |
–StopMethod |
Main |
Method name if differs then main |
–StopMode |
executable |
Can one of jvm java or exe |
–StopTimeout |
No Timeout |
Defines the timeout in seconds that procrun waits for service to exit gracefully. |
–LogPath |
working path |
Defines the path for logging |
–LogPrefix |
jakarta_service |
Defines the service log filename |
–LogLevel |
INFO |
Defines the logging level and can be either error, info, warn or debug |
–StdOutput |
|
Redirected stdout filename |
–StdError |
|
Redirected stderr filename |
請依版本參考相關文件:
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html
近期留言