简体   繁体   中英

Load Play! environment mode in another main process

I have a Play application that contains a Main running another process. At Heroku, it is another dyno running this process.

I need to load the Mode (Dev, Test, Prod) which my Play application is running into the Main process Application , here:

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.

You can pass the -main option to the target/universal/stage/bin command in your Procfile . 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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