Ashok Krishnamoorthy Ashok Krishnamoorthy - 1 month ago 12
Scala Question

Play 2.5.6 application on Tomcat or any alternative?

I have created an application on Play framework 2.5.6. I am trying to find out what is the best way to deploy the application on production. I have tomcat installed on my Ubuntu machine. How to create war file and How to deploy on tomcat? I am using Scala Eclipse IDE for development.

Nio Nio

Have a look at this other thread which is very similar to what you're asking here (albeit directed at GAE).

In a nutshell, the disadvantages of deploying your app to Tomcat are:-

  • you have extra work to do to package your application as a WAR
  • extra work to deploy it
  • your application may not be fully asynchronous running in Tomcat

As that outdated documentation suggests - the simplest way of deploying your app in production is just using the version of Netty which is packaged as part of a Play application. See the relevant version of the docs to create a distribution. You only need a relevant version of a JVM on your prod server in this case.

The flow is generally:-

  1. Run $ dist to build the binary (this is a zip by default, but you can also build a tar if you prefer using $ universal:packageZipTarball instead of dist).
  2. Move it into your Linux production environment
  3. Unpack it
  4. Set permissions if you build a zip $ chmod +x /path/to/bin/<project-name> (not required if you created the tar)
  5. Run the app start script (created by the dist task) eg. $ target/universal/stage/bin/<project-name>