The question is: how do I retrieve the port number that play is listening on, no matter how it was defined (configuration, command line argument, or not at all).
Thi
I'm using this Scala snippet to determine Play's listen port. Unfortunately I had to hard code some default values, in case -Dhttp.port=... is not specified.
val listenPort =
if (!Play.isTest) {
System.getProperty("http.port", "9000")
}
else {
// Not on classpath: play.api.test.Helpers.testServerPort
// Instead, duplicate its implementation here:
System.getProperty("testserver.port", "19001")
}
I also wonder if there is no better way, e.g. Play.port but I haven't found anything — well except for your question :-)
(In your example, it should be -Dhttp.port=80 not -Dhttp.port 80.)