Java Programm als Windows Service

  • Beitrags-Autor:
  • Beitrags-Kategorie:Sonstiges

WinSW wraps and manages any application as a Windows service.

<service>
  <id>xyz</id>
  <name>XYZ</name>
  <description>This service runs XYZ.</description>
  <workingdirectory>D:\xyz\xyzzip</workingdirectory>
  <!-- env name="CLASSPATH_PREFIX" value="D:\xyz\libs\ojdbc6.jar" / -->
  <env name="XYZ_WEB_SCHEME" value="https" />
  <env name="XYZ_WEB_PORT" value="60708" />
  <env name="JAVA_OPTS" value="-DconfigFile=D:\xyz\config\xyz.properties -DtomcatUsersXml=D:\xyz\config\tomcat-users.xml -DxyzJksPath=D:\xyz\ca\xyz.jks -DaccessLogDir=D:\xyz\logs" />
  <env name="JAVA_HOME" value="D:\java\jdk-11.0.24+8" />
  <env name="PATH" value="D:\java\jdk-11.0.24+8\bin;%PATH%" />
  <serviceaccount>
    <domain>abcd</domain>
    <user>admin</user>
    <password>geheim</password>
    <allowservicelogon>true</allowservicelogon>
  </serviceaccount>
  <executable>"%BASE%\xyzzip\target\bin\xyz.bat"</executable>
  <stopexecutable>curl</stopexecutable>
  <stoparguments>--request POST --url https://localhost:60708/cmd/shutdown --header "content-type: text/plain" --header "user-agent: xyz-command" --insecure --data d1kw81a09e</stoparguments>
  <logpath>D:\xyz\logs</logpath>
  <log mode="roll-by-size">
    <sizeThreshold>10240</sizeThreshold>
    <keepFiles>8</keepFiles>
    <zipOlderThanNumDays>5</zipOlderThanNumDays>
  </log>
  <onfailure action="restart" delay="30 sec"/>
  <onfailure action="none"/>
</service>