【问题标题】:Load Play! environment mode in another main process加载播放!另一个主进程中的环境模式
【发布时间】:2019-10-31 16:14:11
【问题描述】:

我有一个包含运行另一个进程的 Main 的 Play 应用程序。在 Heroku,它是另一个运行此过程的测功机。

我需要将我的 Play 应用程序正在运行的模式 (Dev, Test, Prod) 加载到主进程 Application,这里:

val app: Application = GuiceApplicationBuilder().build()

这就是我所拥有的:

object ConsumersApp {


  def main(args: Array[String]): Unit = {
    val app: Application = GuiceApplicationBuilder()
      .loadConfig(env => Configuration.load(env))
      .build()

      //...
  }

}

.loadConfig(env => Configuration.load(env)) 实际上会返回Mode.Test,即使在生产环境中也是如此。

【问题讨论】:

    标签: heroku playframework play-framework-2.7


    【解决方案1】:

    您可以将-main 选项传递给Procfile 中的target/universal/stage/bin 命令。例如:

    worker: target/universal/stage/bin/play-app -main com.example.MyClass
    

    我不确定这个标志是否有规范,但是the code is on Github

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-20
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多