I'd like to start a play application at a random port (port 0). Each started microservice instance should connect to a service locator (eureka) and tell him his port and host. But how can I retrieve the port of a running play service?
This question was actually asked several times, but the answers did not work for me:
class MyModule @Inject() (configuration: Configuration) extends AbstractModule {
configuration.getInt("http.port") // returns None
System.getProperty("http.port") // returns null
}
According to play documentation this should work:
configuration.get[Int]("play.server.http.port")