2011-07-03 2 views
0

약간의 기본적인 질문이 있지만 웹에서 대답을 찾지 못하는 것 같습니다. 배치 파일을 통해 서비스로 tomcat을 자동으로 설정하려고합니다.Tomcat6 서비스 설정; 배치 파일을 사용하여 JvmOptions을 프로그래밍 방식으로 연결하십시오.

내 배치 파일은 현재 다음과 같습니다

set memSize=512 
set jvmOptions="-XX:MaxPermSize=512M" 
ECHO Setting up tomcat as a service. 
call service.bat install 
ECHO Setting the memory allocation to a maximum of %memSize% 
ECHO Using JVM options %jvmOptions% 
Tomcat6 //US// --JvmMx=%memSize% --Startup="auto" --JvmOptions=%jvmOptions% 

내가 직면하고있어 문제는 --JvmOptions 스위치를 실행하면 tomcat6w.exe에 설정된 현재의 모든 자바 옵션을 덮어 쓰기 때문이다.

내 질문은, 누구든지 --JvmOptions 스위치가 전달 된 값을 현재 값의 끝에 연결하는 방법을 알고 있습니까? (내가 제대로 질문을 이해한다면) 내가 한 길고 어려운 검색 코드 예제에서 답을 찾을 수 관리 후 사전

답변

0

이처럼 간단 할 수 없습니다. 그런데 저를 매우 어리 석 게 느끼게 만들려면 대답은 Tomcat6 Windows 서비스 사용 방법 페이지의 here 바로 내 코 밑에있는 것으로 나타났습니다. - with ++ 옵션을 바꾸면 원본을 바꾸는 대신 연결됩니다.

그래서 배치 파일이되었습니다.

set memSize=512 
set jvmOptions="-XX:MaxPermSize=512M" 
ECHO Setting up tomcat as a service. 
call service.bat install 
ECHO Setting the memory allocation to a maximum of %memSize% 
ECHO Using JVM options %jvmOptions% 
Tomcat6 //US// --JvmMx=%memSize% --Startup="auto" ++JvmOptions=%jvmOptions% 

감사합니다.

0

에서

덕분에이

set memSize=512 

REM I removed the quotes and reused the variable in its own definition 
set jvmOptions=%jvmOptions%-XX:MaxPermSize=512M 

ECHO Setting up tomcat as a service. 
call service.bat install 
ECHO Setting the memory allocation to a maximum of %memSize% 
ECHO Using JVM options %jvmOptions% 

REM Added the quotes back here 
Tomcat6 //US// --JvmMx=%memSize% --Startup="auto" --JvmOptions="%jvmOptions%" 
+0

감사합니다.하지만 문제는 jvmOptions이 Tomcat6 서비스 설치와 관련된 환경 변수가 아니라는 것입니다. 도와 주셔서 감사합니다. – Klee

0

이전 게시물이 조금 있지만 Tomcat을 여러 번 설치 제거해야합니다 (예 : 느슨하게 사용하는 용어) 다른 응용 프로그램이 업그레이드되어 설치 프로그램을 사용하지 않는 것과 유사한 작업을 수행하려고합니다. UI 및 일관성 보장.

일부 스크립트 팁

(지금까지 내 경험을 바탕으로) :

REM -- Use variables for the Tomcat install directory & executable: 
set TomcatDir=%ProgramFiles%\Tomcat 
set TomcatExe=%TomcatDir%\bin\Tomcat7.exe 

REM -- If using multiple instances, turn these in to array 
set TomcatInstance[1]=Tomcat7 
set TomcatInstance[2]=MyAppInstance1 
set TomcatInstance[3]=MyAppInstance2 
set TomcatInstance[4]=MyAppInstance3 
set TomcatInstance[5]=MyAppInstance4 

REM -- When updating/adding Java options and you need to use a ";" between 
REM -- values, single-quote the semi-colon, ';' so it isn't intepretted as a CrLf 
REM -- For example, 
call "%TomcatExe%" //US/%TomcatInstance% ++JvmOptions "-Djava.library.path=%TomcatDir%\bin';'%TomcatDir%\endorsed" 

REM -- So to ensure all instances have the same settings... 
for /L %I in (1,1,5) do (
    call "%TomcatExe%" //US/!TomcatInstance[%I]! ++JvmOptions "-Djava.library.path=%TomcatDir%\bin';'%TomcatDir%\endorsed" 
) 

REM -- Block scripts sections with setlocal/endlocal 
REM -- "EnableDelayedExpansion" allows the above delayed variable expansion to occur 
::--==--==--==--==--==--==--==--==--==--== 
:Routine_Name 
::--==--==--==--==--==--==--==--==--==--== 
setlocal EnableDelayedExpansion 
echo script commands go here 
endlocal 
goto :EOF 

참고 :이 실제 스크립트 언어 (VBS, JS 또는 PS)에 훨씬 쉬울 것,하지만 난 스크립트를 떠날 필요 내 현재 공연을 떠나면 누구에게나 나를 대신 할 수있는 "쉬운"수정.

FWIW, Tomcat7의 의사는 http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html입니다.

관련 문제