4

We've developed a small app using play!, and it runs standalone on a user's computer (Windows XP or Windows 7), as the users don't have network access. Currently, it runs within a console/command window. I would like to make it so there's no console window in the taskbar where play is running--really, mostly because the users are prone to closing the the window. I came up with a couple of ideas, but I was hoping for some validation or other ideas.

First, I was thinking of running Java via javaw, which is typically what runs for GUI applications running Java--but what would I run? I guess I could run the Winstone Servlet container with the WAR output of play! (mentioned as a solution to the other stackoverflow question below).

Second, I was thinking of trying to wrap it in a windows service.

This question is similar, but slightly different (I don't mind installing play!, which just involves unzipping the framework): Deploy Play! application as executable jar

Has anyone used either of these techniques, or is there a better way? Pros/Cons/Examples?

Thanks!


Update: Any comments about Winstone? It turns out that due to security constraints, we'll not be able to [easily] create services or scheduled tasks (as SYSTEM). Thanks again.

Community
  • 1
  • 1
Eve Freeman
  • 32,467
  • 4
  • 86
  • 101
  • There's a similar [question/answer](http://stackoverflow.com/questions/12120489/how-do-i-run-a-play-framework-2-0-application-as-a-windows-service) that also describes the yajsw approach. – jl. Jan 30 '13 at 07:53

4 Answers4

2

I have done something similar for a few applications. The steps I carried out are

  1. Create a bat file that launches the play app. This could be as simple as play run or play start
  2. Create a scheduled task that executes on system startup, using SYSTEM as the user profile to run the command as.

This approach has been working on my internal systems for well over a year.

Codemwnci
  • 54,176
  • 10
  • 96
  • 129
  • Yeah, we actually were trying this sort of thing in our development environment, but I don't think we'll be able to set up scheduled tasks as system in the target environment. – Eve Freeman Mar 13 '12 at 23:54
2

Alternatively you can use yajsw to wrap your play application as a windows service. It works really well and is easy to set up.

The only issue I have encountered is that on one of my box running on Windows Server 8 R2, some of the jobs are duplicated when the scheduler kicks off. I am not convinced it is directly related to yajws and I have not been able to reproduce the error on other environments with the same setup.

I managed to work around it by adding a synchronization block in my doJob method. Have a look here for info for setting up yajws with play.

emt14
  • 4,846
  • 7
  • 37
  • 58
0

I am not sure if play would work on winstone. A list of application servers known to work with play can be found here.

You will need to war your play application with play war myapp -o myapp.war and test it first.

emt14
  • 4,846
  • 7
  • 37
  • 58
  • That's a good point, I suppose a few of those are Java based and can run fairly simply with javaw--I'll give Jetty a try. – Eve Freeman Mar 17 '12 at 18:32
0

I ended up creating a batch file that runs "play run", and a runnable JAR that calls "start /B runPlay.bat" as a system call. This way, the console window doesn't start up at all. It works great so far. There seem to be a variety of solutions, but this was fairly simple.

Eve Freeman
  • 32,467
  • 4
  • 86
  • 101