Eve Freeman
Eve Freeman

Reputation: 33175

Play! framework deployed as a JAR or Service?

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.

Upvotes: 4

Views: 4394

Answers (4)

Eve Freeman
Eve Freeman

Reputation: 33175

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.

Upvotes: 0

emt14
emt14

Reputation: 4896

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.

Upvotes: 0

emt14
emt14

Reputation: 4896

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.

Upvotes: 2

Codemwnci
Codemwnci

Reputation: 54914

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.

Upvotes: 2

Related Questions