The recommended way to run Play! app in production is to run it in a standalone mode, not in a application server environment. There are plugins that can build the *.war file for you, however, if that's the way you prefer to go forward. Particularly, take a look at this one: https://github.com/play2war/play2-war-plugin
I would still suggest that you do the recommended, standalone deployment. We have a good experience with sbt-native-packager SBT plugin. It can build deb
and rpm
files, with support of System V or Upstart startup scripts. There is more information on the Play! Production page.
To use the sbt-native-packager
, you'll need to add it to your project/plugins.sbt
file first. Just like this: addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.0-RC2")
.
Then in the build.sbt
you'll have to configure the necessary properties of the package, as described on the Production
page linked above. I'll copy some of the configuration from that page here. Let's say, you'll use rpm
format to deploy on CentOS. Here's what you need to put in your build.sbt
:
lazy val root = (project in file("."))
.enablePlugins(PlayScala, RpmPlugin)
maintainer in Linux := "First Lastname <[email protected]>"
packageSummary in Linux := "My custom package summary"
packageDescription := "My longer package description"
rpmRelease := "1"
rpmVendor := "example.com"
rpmUrl := Some("http://github.com/example/server")
rpmLicense := Some("Apache v2")
Then start sbt
from command line and execute this command: rpm:packageBin
. It will build your app and create the rpm
file, which will be placed and named like this: ./target/rpm/RPMS/noarch/your-application-name.noarch.rpm
.
From there, it's a standard rpm
that you could deploy and start as usual.