Scala Play framework web application hosting Process
Asked Answered
V

1

3

I'm working in a web project using scala and play framework. I`m worried about application deployment part. I need to host my application in a Glass fish server. So anyone has experience in that? I have experience in hosting javaEE apps upload the .war file to the server. but how can I host play application like that? i have refer following article and build the dist. Production Dist

If anybody can give me the instructions step by step it easy to understand it to me. Thanks

Verticillate answered 26/2, 2016 at 7:27 Comment(1)
I don`t have idea how and what should i upload to server. I have created a zip file using this article (playframework.com/documentation/2.1.x/ProductionDist). with that how can I host my application in a server like glassfishVerticillate
T
7

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.

Transcribe answered 26/2, 2016 at 10:5 Comment(2)
Great answer. It might be a stupid question, but after you build an rpm (or any other format) and start the app, the application will run in a jvm. How do you specify the settings of the JVM (heap space, etc..)Voyageur
SBT native packager plugin allows you to configure JVM parameters. Have a look here: scala-sbt.org/sbt-native-packager/archetypes/java_app/…Transcribe

© 2022 - 2024 — McMap. All rights reserved.