简体   繁体   English

加载播放! 另一个主进程中的环境模式

[英]Load Play! environment mode in another main process

I have a Play application that contains a Main running another process.我有一个包含运行另一个进程的 Main 的 Play 应用程序。 At Heroku, it is another dyno running this process.在 Heroku,它是另一个运行此过程的测功机。

I need to load the Mode (Dev, Test, Prod) which my Play application is running into the Main process Application , here:我需要将我的 Play 应用程序正在运行的 Mode (Dev, Test, Prod)加载到主进程Application中,这里:

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

This is what I have:这就是我所拥有的:

object ConsumersApp {


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

      //...
  }

}

But .loadConfig(env => Configuration.load(env)) actually returns Mode.Test even when in production environment.但是.loadConfig(env => Configuration.load(env))实际上返回Mode.Test即使在生产环境中。

You can pass the -main option to the target/universal/stage/bin command in your Procfile .您可以将Procfile -maintarget/universal/stage/bin命令。 For example:例如:

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

I'm not sure if there is a specification for this flag, but the code is on Github我不确定这个标志是否有规范,但代码在 Github

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

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