[Windows] Winsw

在Windows 啟動後執行執行程式, 正常可以透過service 使它可以有不用登入下啟動, 然而若要執行exe 或jar 的話, 就不能夠順利進行. 而Winsw 便應運而生.Winsw 是一個轉接器(wrapper) 將exe 轉換成service 執行. 而其中的設定則透過xml 存取.  在示範中, 則以啟動EnonicXP, 一個Java CMS 作示範.

<service>
  <id>EnonicXPService</id>
  <name>Enonic XP Service</name>
  <description>This service runs Enonic XP serving the Intranet.</description>
  <env name="JAVA_HOME" value="C:\software\jdk.8.0_101"/>
  <env name="XP_INSTALL" value="C:\server\enonic-xp-intranet"/>
  <env name="XP_HOME" value="%XP_INSTALL%-home"/>
  <env name="DEFAULT_JAVA_OPTS" value="-agentpath:C:\software\yourkit-win64\yjpagent.dll -server -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -Xms6g -Xmx6g"/>
  <executable>%JAVA_HOME%\jre\bin\java.exe</executable>
  <arguments>%DEFAULT_JAVA_OPTS% -Dxp.install=%XP_INSTALL% -Dfile.encoding=UTF8 -classpath "%XP_INSTALL%\lib\*" com.enonic.xp.launcher.LauncherMain</arguments>
  <log mode="roll-by-size">
    <sizeThreshold>10240</sizeThreshold>
    <keepFiles>3</keepFiles>
  </log>
  <onfailure action="restart"/>
  <serviceaccount>
   <domain>mycompanydomain.test</domain>
   <user>serviceuser-test</user>
   <password>secretpassword</password>
   <allowservicelogon>true</allowservicelogon>
  </serviceaccount>
</service>

參考資料

About C.H. Ling 262 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.