Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between Play run and start?

I would like to understand the differences between running play start and play run, in the context of the problem below.

My specific use case is rather complex, but I'll simplify it like this:

  • On startup (as part of Global.scala), my Play application is making a direct method call to the entry point of a Java application X.
  • As part of its initialization, X starts an embedded instance of Tomcat.
  • At the end of X's initialization, it verifies that Tomcat is up and responding to requests.

Now, when I do play start on this application, Tomcat is up and running, X is happy, and life goes on.

However, when I do play run, Tomcat fails to initialize, and X sits there waiting for a response, eventually timing out.

The main reason I need to use play run is for development, since I'd like to attach the Eclipse debugger to play by running play debug run.

I realize this is an oversimplification, but what I'm hoping to get from you are leads to differences between Play run and Play start that could make a difference in the behaviour of my application resulting in this failure.

Now, I've tried increasing the number of threads in Play's default thread pool following http://www.playframework.com/documentation/2.1.x/ThreadPools but no luck.

Play output and logs give me no useful information on this issue.

I'm using Play 2.1.1

like image 936
Alejandro Lujan Avatar asked Aug 13 '13 15:08

Alejandro Lujan


1 Answers

  • play run starts the play application in development mode.

    This means it runs from within the play prompt (within SBT, really), with some custom classloader magic to allow auto-reloading of classes, auto-compilation of templates, etc. This custom way of running the application is probably what prevents Tomcat from starting.

    Without some log output or stack traces from Tomcat, it is difficult to say much more about why Tomcat does not start. This is a bit similar to starting Tomcat within another container that provides isolation through custom classloaders (like... Tomcat).

    Edit: I do not know the gory details myself, but it all happens in the play run command and the reloader. It seems to be more documented in master, although I do not know if things have changed between 2.1.x and 2.2.x.

  • play start is a interactive way to run the application in production mode.

    This means it is completely identical to a call to java -cp [...] YourMainClass, except it runs interactively from the play prompt (needs Ctrl+D to detach) and not in the background (and as such it is not suitable for automated deployment).

However for real production you should prepare a standalone version with play dist command and then start it with included script as described in the documentation.

like image 64
gourlaysama Avatar answered Oct 05 '22 15:10

gourlaysama