How to start Play! Framework 2.0 application as a Windows service

Clip to Evernote

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.

  1. Build your application for deploy.

  2. Deploy your application by using the stage task.

    $ play clean compile stage
  3. Download ‘Yet Another Java Service Wrapper’ (YAJSW).

  4. Unzip YAJSW to %app% (where %app% is the path to your application) and rename the directory to wrapper.

  5. Create 2 directories: %app%\log (for log files) and %app%\temp (for temporary files).

  6. 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 = play.core.server.NettyServer = ${wrapper.working.dir}/conf/* = ${wrapper.working.dir}/target/staged/* =
    wrapper.console.title = Play! service test = Play! service test
    wrapper.ntservice.displayname = Play! service test
    wrapper.ntservice.description = Running a Play! app as windows service
  7. Execute %app%\wrapper\bat\runConsole.bat and confirm your application starts.

  8. Install the service. Execute %app%\wrapper\bat\installService.bat. The new Play! service test service should be created.

  9. Start the service via Service in Computer Management.

Tags: ,

5 Responses to “How to start Play! Framework 2.0 application as a Windows service”

  1. Maurice Betzel says:

    There is a good possibility to run the PLAY! framework as windows service with JNA. I deployed several java implementations in this way on windows server 2008 SP2 successfully being monitored by PRTG (which has not intervened in a period of 6 months until now). If we decide to use PLAY! in our web stack i will write an article about it and publish it here.

  2. Thanks, that was exceedingly helpful! I was already gearing up for a long struggle getting my application to run as a service with Apache procrun, but YAJSW is a joy to use, and with your example it was a breeze to get going.

  3. laguiz says:

    Help me to get a windows service that can be started/stopped and even restarted successfully. Thanks!

  4. Adrian says:

    Thank you. This is really great information and easy to follow.

  5. application.conf fails to load because setting cp to = ${wrapper.working.dir}/target/staged/*
    tries to load it from jars inside conf directory, but conf directory contains conf files themselves.

    Setting = ${wrapper.working.dir}/target/staged solves the problem.

Leave a Reply to Thomas Themel

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">