Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

playframework - How do I run a Play Framework 2.0 application as a Windows service?

I have a Play Framework 2.0 application that I want to deploy (production) on Windows Server 2008 R2. How do I get it to run as a service?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This worked for me on Windows 7:

  1. Create folder C:my_app
  2. Go to your Play! app folder in command line and type

    play dist

  3. Copy generated "something-SNAPSHOT" folder to C:my_app
  4. Download YAJSW and extract to C:my_app
  5. In C:my_appsomething-SNAPSHOT make a new file start.bat and fill it with command like this:

    java -cp "C:my_appsomething-SNAPSHOTlib*" play.core.server.NettyServer

  6. Save it and launch start.bat. Your play app must start and work as usual. Take a look at server's PID. You will use it in the next step.

  7. Now using command prompt go to C:my_appyajswat and type

    genConfig.bat < PID from previous step >

  8. You generated C:my_appyajswconfwrapper.conf. Edit this file and change these params like so:

    wrapper.ntservice.name=My App Name
    wrapper.ntservice.displayname=My App Name


    Save file.

  9. Terminate the start.bat script you started in 6. then, in C:my_appyajswat launch

    runConsole.bat

    If app starts, do a Ctrl c (and answer y) to terminate the batch file and proceed to next step.

  10. To install service launch (Run as administrator)

    installService.bat

  11. To start service launch

    startService.bat

Now you can see your "My App Name" service in Windows services. To stop service you can use stopService.bat. To uninstall it uninstallService.bat.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...