Friday, November 16, 2012

Play framework: develop with custom domain and port

What it's about

This howto shows you how to use a custom host name and port number when developing with the play framework v2.

Why would you do that? 

In my case it's because I want the development environment to be as close to the final production environment as it can be.

Assumptions

You have play v2 installed, you start it command line, and you're developing with remote debugging in IntelliJ or Eclipse or whatever.
Your desired host name is example.com with port 80.

Steps

If your host name is not in the dns then add a hosts entry. It must point to your local ip address (such as 192.168.1.1), not to the loopback address 127.0.0.1.


By default, Skype listens on port 80 for incoming connections. Either shut down Skype completely for the time of development, or configure it to NOT listen on port 80. Just shutting it down for the moment of starting the embedded play server (Netty) isn't enough, because after a while Skype gets a hold if the port again.









In the console, type "play debug" as usual. But this time run with "run 80 -Dhttp.address=example.com".

Test it in the browser.

Final notes

There is no configuration within play for the port or host. If you deploy your app then you probably have that kind of config in Tomcat or so.

More info:
http://www.playframework.org/documentation/2.0.4/ProductionConfiguration
http://www.playframework.org/documentation/2.0.4/HTTPServer

As of now (version 2.0.4) running on a certain port (such as run 80) does not complain when another application or service is occupying that port already.

No comments:

Post a Comment