Scala Play framework web application hosting Process

随声附和 提交于 2019-12-05 02:44:34

问题


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


回答1:


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 <first.last@example.com>"

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.



来源:https://stackoverflow.com/questions/35645910/scala-play-framework-web-application-hosting-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!