Allow port when launching application to play

Can I allow which port the playback application is running on? When I launch the game on port 9001 using sbt:

> run 9001 

I want to somehow select this code in the code:

 Play.current.getCurrentPort() == 9001 // true 

Is there such a method?

+4
source share
1 answer

As you can see in the documentation for Configuration , the default port is 9000.

That means you should be able to do

 val port = Play.current.configuration.getInt("http.port").getOrElse(9000) 

But for this you will need to run the application using

 > run -Dhttp.port=9001 

There may be other ways, but this is one possible solution.

+1
source

Source: https://habr.com/ru/post/1501455/


All Articles