6

I'm creating a packaged project usingdist and am trying to modify the generated start script to run the app on port 9001.

Here is what is generated:

exec java $* -cp "`dirname $0`/lib/*" play.core.server.NettyServer `dirname $0`

Here is what I tried, which doesn't seem to work.

exec java $* -Dhttp.port=9001 -cp "`dirname $0`/lib/*" play.core.server.NettyServer `dirname $0`

Any ideas?

I've also tried specifying http.port=9001 in application.conf with no avail. It was very easy to do this in Play 1.2.X, seems a step backward.

1 Answers1

7

After running play dist and then extracting the generated bundle, you can start Play 2 on a different port by running:

./start -Dhttp.port=5432

Or if you would rather edit the start script you can update it to be:

#!/usr/bin/env sh

exec java $* -Dhttp.port=5432 -cp "`dirname $0`/lib/*" play.core.server.NettyServer `dirname $0`

And then run:

./start
James Ward
  • 29,283
  • 9
  • 49
  • 85
  • So you want to modify the start script rather than pass a parameter to the start script? – James Ward Oct 30 '12 at 21:09
  • I tried passing a parameter to the generated script. It's not the target/start script. It's the start script generated after running play dist. –  Oct 30 '12 at 21:12
  • Sorry. Usually I use `play stage`. I've updated the instructions for using `play dist` and tested them on Linux. If this doesn't work for you, maybe it's a bug in your version of Play. Or an OS specific bug. In that case let me know what version of Play and what OS you are using. – James Ward Oct 30 '12 at 21:17
  • BTW, the `$*` in the script just takes all of the command params and passed them to the `java` command. So if specifying `-Dhttp.port` doesn't work as a param to `start` then it's not going to work to modify the command. – James Ward Oct 30 '12 at 21:19
  • Right, I figured that. Hmmm. Something is fishy here. Let me get back to you! –  Oct 30 '12 at 21:23
  • @JamesWard Is this supposed to work in Play 2.2(+) as well? I know `start` is replaced with my application name but if I set `-Dhttp.port=80` it still listens on port 9000. (No errors, Windows 8, play 2.2.2) – Aerus Apr 25 '14 at 15:08
  • It actually looks like it does still work on Linux which is actually all I need. – Aerus Apr 25 '14 at 15:15
  • Here is a better answer to this question: http://stackoverflow.com/questions/8205067/how-do-i-change-the-default-port-9000-that-play-uses-when-i-execute-the-run/8206747#8206747 – James Ward Apr 25 '14 at 18:42