Running XP as a service in windows


#1

Enonic version: 6.5
OS: Windows

How can you set XP to run as a service in windows?

-kjetil


#2

Is there a special reason for this? :slight_smile:

In any case Windows has the Task Scheduler (Start menu, then type Schedule task) which might do what you request.
Also I have not tried it, but http://nssm.cc/usage seems to be recommended.

And at last is the Docker-way by downloading the docker-compose setup from Enonic-cloud repo. This setup will restart the containers as long as the docker daemon is running. But then docker is the “service”, on the upside the installation can be ported to any host that runs docker.

To change XP-version edit the Dockerfile in the exp folder.
PSA: The Docker beta for Windows and Mac is the recommended way to install docker on Windows.


#3

I have successfully tested kohsuke’s wrapper executable WinSw to set up a windows service with logrotate and service user. It includes a windows-service.exe file and windows-service.xml file that can be used to run windows-service [install | uninstall]

Here is an example configuration:

<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\1.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>

#4

Here is a brand new guide for running XP 7 as a windows service :slight_smile:
https://developer.enonic.com/guides/run-xp-as-a-service