다음과 같이 bat 파일로 만들면 알아서 등록을 해준다.

가능하면 current_dir 안에 tomcat과 jdk가 같이 있으면 좋다.

나는 openJDK zulu를 사용했는데, 그냥 zip 파일 받아서 압축풀면 끝.



@ECHO OFF

set current_dir=%~dp0

set SERVICE_NAME=myApp

set EXECUTABLE="%current_dir%Tomcat\bin\tomcat9.exe"

set CATALINA_HOME=%current_dir%\Tomcat

set CATALINA_BASE=%CATALINA_HOME%

set "CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar"

set ENDORSED_PROP=ignore.endorsed.dirs

set SERVICE_STARTUP_MODE=auto

set JvmArgs=

set JVM=%current_dir%zulu\jre\bin\server\jvm.dll

set JvmMs=1024

set JvmMx=2048

 

ECHO @@@ Delete old service.

sc stop %SERVICE_NAME%

sc delete %SERVICE_NAME%

 

ECHO @@@ Register a new service.

 

 

%EXECUTABLE% //IS//%SERVICE_NAME% ^

    --Description "Apache Tomcat 9.0.10 Server - http://tomcat.apache.org/" ^

    --DisplayName "%SERVICE_NAME%" ^

    --Install "%EXECUTABLE%" ^

    --LogPath "%CATALINA_BASE%\logs" ^

    --StdOutput auto ^

    --StdError auto ^

    --Classpath "%CLASSPATH%" ^

    --Jvm "%JVM%" ^

    --StartMode jvm ^

    --StopMode jvm ^

    --StartPath "%CATALINA_HOME%" ^

    --StopPath "%CATALINA_HOME%" ^

    --StartClass org.apache.catalina.startup.Bootstrap ^

    --StopClass org.apache.catalina.startup.Bootstrap ^

    --StartParams start ^

    --StopParams stop ^

    --JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-D%ENDORSED_PROP%=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;%JvmArgs%" ^

    --JvmOptions9 "--add-opens=java.base/java.lang=ALL-UNNAMED#--add-opens=java.base/java.io=ALL-UNNAMED#--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED" ^

    --Startup "%SERVICE_STARTUP_MODE%" ^

    --JvmMs "%JvmMs%" ^

    --JvmMx "%JvmMx%"

%EXECUTABLE% //US//%SERVICE_NAME% ++JvmOptions="-XX:MaxPermSize=512m"

 

ECHO @@@ Service start.

sc start %SERVICE_NAME%

 

timeout 5

 

 


Posted by motolies
,