Run a Play framework application as a Windows Service with YAJSW kindly explains how to run a Play! 1.x applications as a Windows Service, but unfortunately it does not work for Play! 2.0 application. I could not find the good solution for Play! 2.0 applications on the internet, so I note my solution. Hope it would be someone’s help.
- Build your application for deploy.
-
Deploy your application by using the stage task.
$ play clean compile stage
- Download Yet Another Java Service Wrapper (YAJSW).
- Unzip YAJSW to
%app%
(where%app%
is the path to your application) and rename the directory towrapper
. - Create 2 directories:
%app%\log
(for log files) and%app%\temp
(for temporary files). -
Edit
%app%\wrapper\conf\wrapper.conf
.Example (please change
PATH_TO_YOUR_APP
to%app%
):# Example YAJSW configuration to run Play! application as service wrapper.working.dir=PATH_TO_YOUR_APP wrapper.java.app.mainclass = play.core.server.NettyServer wrapper.java.classpath.1 = ${wrapper.working.dir}/conf/* wrapper.java.classpath.2 = ${wrapper.working.dir}/target/staged/* wrapper.java.additional.1 = -Djava.io.tmpdir=temp wrapper.logfile=${wrapper.working.dir}/logs/wrapper.log wrapper.console.title = Play! service test wrapper.ntservice.name = Play! service test wrapper.ntservice.displayname = Play! service test wrapper.ntservice.description = Running a Play! app as windows service
- Execute
%app%\wrapper\bat\runConsole.bat
and confirm your application starts. - Install the service. Execute
%app%\wrapper\bat\installService.bat
. The newPlay! service test
service should be created. - Start the service via
Service
inComputer Management
.