Play框架创建DEB并将其部署在Ubuntu 14.04上



我正在使用带有Scala的Play Framework 2.3.8,并且我正在尝试创建DEB包以将其安装在生产服务器上。安装后,它应该通过"服务"自动运行

我已添加到build.sbt

import com.typesafe.sbt.packager.Keys._
packageDescription := """Admin Application"""
maintainer := """Admin <contact@maintainer.com>"""

执行后

activator debian:packageBin

它生成deb文件,但安装脚本后/etc/init.d/testApplication不起作用

如何让它在 Ubuntu 14.04 上运行?

我试图使用基于 http://www.scala-sbt.org/sbt-native-packager/archetypes/java_server/的Java Application Archetype

我添加了:

import com.typesafe.sbt.SbtNativePackager._
import NativePackagerKeys._
packageArchetype.java_application

但门槛没有成功

===

== 更新

设置Upstart后,在安装过程中我得到:

Selecting previously unselected package testApplication.
(Reading database ... 61317 files and directories currently installed.)
Preparing to unpack testApplication_0.1_all.deb ...
Unpacking testApplication (0.1) ...
Setting up testApplication (0.1) ...
Creating system group: testApplication
Adding group `testApplication' (GID 115) ...
Done.
Creating user testApplication in group testApplication
start: Unknown job: testApplication
testApplication could not be started. Try manually with service testApplication start
Processing triggers for ureadahead (0.100.0-16) ...

手动运行脚本仍然没有给出任何结果

michal@cantrace:~$ sudo /etc/init.d/testApplication start
 * Starting testApplication                                  [ OK ]
michal@cantrace:~$ ps aux |grep java
michal    1807  0.0  0.0  11744   920 pts/0    S+   18:33   0:00 grep --color=auto java

我在 Debian 上遇到了类似的问题。 DEB 包的默认配置已损坏。 默认情况下,应用程序将在启动时以/usr/share/[your application name]创建RUNNING_PID文件。 这将由于文件权限无效而失败。 要修复:

  • 安装 DEB 包后,编辑/etc/default/[your applicaiton name]并取消注释以下行并重新启动服务:

    -Dpidfile.path=/var/run/[your application name]/play.pid

  • 或者,将 sbt-native-packager 升级到 v1.0.0 并覆盖默认配置。

要升级,

  1. [project root]/project/plugins.sbt,添加:

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0")

  1. [project root]/build.sbt 中,删除以下导入:


//import com.typesafe.sbt.SbtNativePackager._ //import NativePackagerKeys._

  1. 创建[project root]/dist/conf/application.ini并指定新的默认值:


# Since play uses separate pidfile we have to provide it with a proper path -Dpidfile.path=/var/run/[your application name]/play.pid

希望对您有所帮助。

DebianLike 系统中有两个基本的服务管理器。

  • Upstart Ubuntu 14 的代言人
  • SystemV Debian 7 的默认值

根据目标系统,您应该使用UpstartSystemV

import com.typesafe.sbt.packager.archetypes.ServerLoader.YourServiceManager
packageArchetype.java_server
serverLoading in Debian := YourServiceManager

Upstart将其脚本存储在/etc/init

SystemV将其脚本存储在/etc/init.d

在这里,您可以获得有关此配置的详细信息:

http://www.scala-sbt.org/sbt-native-packager/archetypes/java_server/index.html#customize

最新更新