Play框架创建DEB并在Ubuntu 14.04

时间:2015-04-22 13:35:06

标签: scala ubuntu playframework playframework-2.0 sbt

我正在使用Play Framework 2.3.8和Scala,我正在尝试创建DEB包以在prod服务器上安装它。安装后,它应自动运行“服务”

我已添加到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

1 个答案:

答案 0 :(得分:4)

我在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中,添加:
  2.   

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

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

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

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

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

        希望它有所帮助。