Play运行和开始之间有什么区别?

Play运行和开始之间有什么区别?

问题描述:

在以下问题的背景下,我想了解跑步比赛开始与比赛跑步之间的区别.

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:

  • 在启动时(作为Global.scala的一部分),我的Play应用程序正在直接调用Java应用程序X的入口点.
  • 作为初始化的一部分,X启动了Tomcat的嵌入式实例.
  • 在X初始化结束时,它会验证Tomcat是否已启动并响应请求.

现在,当我在此应用程序上执行play start时,Tomcat已启动并正在运行,X很高兴,而且生活还在继续.

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

但是,当我执行play run时,Tomcat无法初始化,并且X坐在那里等待响应,最终超时.

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

我需要使用play run的主要原因是为了开发,因为我想通过运行play debug run附加Eclipse调试器来播放.

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.

我意识到这太过简单了,但是我希望从您那里得到的是导致Play run和Play start之间的差异,这可能会导致我的应用程序行为发生变化,从而导致失败.

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.

现在,我已经尝试在 http之后增加Play的默认线程池中的线程数://www.playframework.com/documentation/2.1.x/ThreadPools 但没有运气.

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.

我正在使用Play 2.1.1

I'm using Play 2.1.1

  • play run开发模式启动播放应用程序.

    • play run starts the play application in development mode.

      这意味着它从播放提示(实际上在SBT内)内运行,并带有一些自定义类加载器魔术,以允许自动重新加载类,自动编译模板等.这种运行应用程序的自定义方式可能是阻止Tomcat启动.

      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.

      没有来自Tomcat的某些日志输出或堆栈跟踪,很难说出更多有关Tomcat无法启动的原因.这有点类似于在另一个容器中启动Tomcat,该容器通过自定义类加载器(例如Tomcat)提供隔离.

      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是在生产模式中运行应用程序的交互式方式.

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

      这意味着它与对java -cp [...] YourMainClass的调用完全相同,不同之处在于它是从播放提示中交互式运行(需要Ctrl+D进行分离),而不是在后台运行(因此,它不适合自动部署) .

      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).

      但是,对于实际生产,您应该使用play dist命令准备一个独立版本,然后按照文档中.

      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.