简体   繁体   English

如何在没有SBT插件的情况下启动Play应用程序?

[英]How to start Play application without SBT plugin?

Context. 语境。

I'm looking for a way to start a Play application from within a command line tool. 我正在寻找一种从命令行工具启动Play应用程序的方法。 This needs to be dependent on the task that needs to be performed, namely an OAuth authorisation. 这需要取决于需要执行的任务,即OAuth授权。 When the users selects the task, the tool should spawn a browser window that completes the user authentication. 当用户选择任务时,该工具应产生一个浏览器窗口,以完成用户身份验证。 When this completes, the rest of the authorisation process continues in the Play app. 完成此操作后,其余的授权过程将继续在Play应用中进行。 Once the security token is obtained, the Play app needs to shut down. 获取安全令牌后,Play应用需要关闭。

Question. 题。

Is there a simple way to start (and shutdown) a Play application without using the SBT plugin (provided by Typesafe)? 是否有一种简单的方法可以在不使用SBT插件(由Typesafe提供)的情况下启动(和关闭)Play应用程序?

You may want to have a look at ProductionDist : 您可能想看看ProductionDist

In SBT run task dist (or from CLI activator dist or sbt dist ). 在SBT中运行任务dist (或从CLI activator distsbt dist )。 It will create a ZIP containing your application and its dependencies, plus a run script in a `bin/' sub-directory. 它将创建一个ZIP文件,其中包含您的应用程序及其依赖项,以及在bin /子目录中的运行脚本。

From directory created by extracting the ZIP content, you can so run the application executing the provided script: ./bin/my-app (assuming your application is named "my-app"). 因此,从提取ZIP内容所创建的目录中,您可以运行执行提供的脚本的应用程序: ./bin/my-app /my-app(假设您的应用程序名为“ my-app”)。

It will also create a file named RUNNING_PID containing the PID (process ID) of the JVM running your application, so that if in background (dettached from the CLI) you can kill it properly: 它还将创建一个名为RUNNING_PID的文件,其中包含运行您的应用程序的JVM的PID(进程ID),因此,如果在后台(从CLI分离),则可以正常杀死它:

kill `cat /path/to/RUNNING_PID`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM