将Play应用程序部署为Debian软件包

时间:2015-08-04 18:20:37

标签: ubuntu playframework debian dpkg

我在创建Play应用程序的debian发行版时遇到了一些问题。 deb文件已正确创建,我可以在Ubuntu 15.04上安装它,但无法安装启动和停止服务:

myusr@myhost:~/dev/projects/test/target$ sudo dpkg -i test_0.2_all.deb 
Selecting previously unselected package test.
(Reading database ... 350339 files and directories currently installed.)
Preparing to unpack test_0.2_all.deb ...
Unpacking test (0.2) ...
Setting up test (0.2) ...
Adding test to autostart using update-rc.d
update-rc.d: error: initscript does not exist: /etc/init.d/test
Failed to start test.service: Unit test.service failed to load: No such file or directory.
test could not be registered or started

我还尝试在包中包含application.conf的“生产版本”和一些jvmopts,也没有运气(deb文件来自/ conf的application.conf版本,而不是来自src / universal / conf -is,正确的路径? - ,jvmopts似乎完全被忽略了。)

这是我在项目中使用的build.sbt:

import RjsKeys._

import com.typesafe.sbt.packager.archetypes.ServerLoader.{SystemV, Upstart}

serverLoading in Debian := SystemV

bashScriptConfigLocation := Some("${app_home}/../conf/jvmopts")

bashScriptExtraDefines += """addJava "-Dconfig.file=${app_home}/../conf/application.config""""

name := """test"""

version := "0.2"

maintainer in Linux := "Me <me@mail.com>"

packageSummary in Linux := "Test"

packageDescription := "Test"

daemonUser in Linux := normalizedName.value

daemonGroup in Linux := (daemonUser in Linux).value

doc in Compile <<= target.map(_ / "none")

lazy val root = (project in file(".")).enablePlugins(PlayScala,JavaServerAppPackaging,DebianPlugin)

linuxPackageMappings in Debian := linuxPackageMappings.value

scalaVersion := "2.11.1"

pipelineStages := Seq(rjs, digest, gzip)

resolvers += Resolver.sonatypeRepo("snapshots") 

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws,
  filters,
  "org.webjars" %% "webjars-play" % "2.3.0",
  "org.webjars" % "jquery" % "2.1.3",
  "org.webjars" % "bootstrap" % "3.3.4",
  "org.webjars" % "bootbox" % "4.4.0",
  "org.webjars" % "angularjs" % "1.3.15",
  "org.webjars" % "angular-ui-bootstrap" % "0.13.0",
  "org.webjars" % "nervgh-angular-file-upload" % "1.1.5-1",
  "org.webjars" % "angular-uuid4" % "0.3.0",
  "org.webjars" % "requirejs" % "2.1.14-1",
  "org.webjars" % "d3js" % "3.5.5-1",
  "org.webjars" % "d3-tip" % "0.6.6",
  "com.google.inject" % "guice" % "3.0",
  "ws.securesocial" %% "securesocial" % "master-SNAPSHOT",
  "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23"
)

scalacOptions ++= Seq(
  "-target:jvm-1.7",
  "-encoding", "UTF-8",
  "-deprecation",
  "-feature",
  "-unchecked",
  "-Xlint",
  "-Ywarn-adapted-args",
  "-Ywarn-value-discard",
  "-Ywarn-inaccessible",
  "-Ywarn-dead-code",
  "-language:reflectiveCalls"
)

fork in run := false

webJarCdns := Map("org.webjars" -> "//cdn.jsdelivr.net/webjars")

1 个答案:

答案 0 :(得分:0)

Failed to start test.service: Unit test.service failed to load: No such file or directory.

...表示程序包构建器未发送或正确安装systemd单元文件,或者未正确使用sysvinit填充程序。你可以运行以下内容:

dpkg -c test_0.2_all.deb 

sudo并非必需。这将列出.deb的文件内容。如果我们在此处看到.service文件,那么我们必须查看该软件包的.postinst文件,看看它是否做了傻事(或者更像是丢失了一些文件) initscript setup stanza)。