1
votes

I already found How do I change the default port (9000) that Play uses when I execute the "run" command?

But it has no answer to this.

This is specific to https://www.playframework.com/documentation/2.5.x/Deploying#Using-the-SBT-assembly-plugin

How can I change port when using assembly deployment option ?

I'm using

proc = new ProcessBuilder(

  "java",

  "-jar",

  "./lib/mode-assembley.jar",

  "-Dhttp.port=1234",

  "-Dplay.crypto.secret=abcdefghijk"



  ).start();

but this is still trying 9000 ! and getting

Bad root server path: /Users/xxxx/project/-Dhttp.port=1234

1

1 Answers

0
votes

I think you're better off running your jar with the java parameter

java -jar ... -Dhttp.port=1234

Or alternatively (and my preferred approach), use different configuration files per environment.

So, in development mode you run:

sbt -Dconfig.resource=application.dev.conf run

And in the file conf/application.dev.conf have all the configuration you want for the development mode. Then in the conf/application.conf you can have the production configuration.

Remember that you can compose those files. So, write them like this:

conf/application.conf

# the assembly command will take this one.
http.port=9000

conf/application.dev.conf

include "application.conf"

#override configuration parameters here for dev mode.
http.port=1234

This way, when you do the assembly, you don't need to worry about it, since it takes by default the conf/application.conf file, the other one will be ignored unless you launch the jar with the parameter of course.

java -jar -Dconfig.resource=application.dev.conf

Or finally override anything with the java parameter

java -jar -Dconfig.resource=application.dev.conf -Dhttp.port=4321

This last one, will launch the app with the dev mode configuration and also overrides the port.