Scala Play framework创建DEB并将其部署在Ubuntu 14.04上

Scala Play framework创建DEB并将其部署在Ubuntu 14.04上,scala,ubuntu,playframework,playframework-2.0,sbt,Scala,Ubuntu,Playframework,Playframework 2.0,Sbt,我将PlayFramework2.3.8与Scala一起使用,并尝试创建DEB包,将其安装在prod服务器上。安装后,应通过“服务”自动运行 我已将以下内容添加到build.sbt: import com.typesafe.sbt.packager.Keys._ packageDescription := """Admin Application""" maintainer := """Admin <contact@maintainer.com>""" 它生成deb文件,但安装

我将PlayFramework2.3.8与Scala一起使用,并尝试创建DEB包,将其安装在prod服务器上。安装后,应通过“服务”自动运行

我已将以下内容添加到
build.sbt

import com.typesafe.sbt.packager.Keys._

packageDescription := """Admin Application"""

maintainer := """Admin <contact@maintainer.com>"""
它生成deb文件,但安装后脚本
/etc/init.d/testApplication
不起作用

我怎样才能让它在Ubuntu 14.04上工作

我试图基于

我补充说:

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

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

  • Upstart
    deafult for Ubuntu 14
  • SystemV
    Debian 7的默认值
根据目标系统,您应该使用
Upstart
SystemV

import com.typesafe.sbt.packager.archetypes.ServerLoader.YourServiceManager

packageArchetype.java_server

serverLoading in Debian := YourServiceManager
Upstart
将it脚本存储在
/etc/init

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

在这里,您可以了解有关此配置的更多信息:


我在Debian上遇到了类似的问题。DEB包的默认配置已损坏。默认情况下,应用程序将在启动时在
/usr/share/[您的应用程序名称]
中创建一个正在运行的\u PID文件。由于文件权限无效,此操作将失败。要修复:

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

    -Dpidfile.path=/var/run/[您的应用程序名]/play.pid

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

升级,

  • [project root]/project/plugins.sbt
    中,添加:
  • addSbtPlugin(“com.typesafe.sbt“%”sbt native packager“%”1.0.0”)

  • [project root]/build.sbt
    中,删除以下导入:
  • //导入com.typesafe.sbt.SbtNativePackager.\u

    //导入NativePackageKey.\u

  • 创建
    [project root]/dist/conf/application.ini
    并指定新的默认值:
  • #由于play使用单独的pidfile,我们必须为其提供正确的路径

    -Dpidfile.path=/var/run/[您的应用程序名]/play.pid


    希望有帮助。

    你说的“不工作”是什么意思?有错误信息吗?脚本是否存在?它显示类似于
    *启动deamon testApplication
    的内容,并且没有java进程,我正在通过
    ps aux | grep java
    进行检查。它是否适用于u,使用debs?在
    应用程序.log
    中有任何消息吗?它甚至没有运行应用程序,没有应用程序.log当我尝试
    sudo service testApplication start
    时,它返回
    start:Unknown job
    。当我尝试
    sudo/etc/init.d/testApplication start
    时,它显示正在启动
    启动testApplication
    ,但没有java进程您的应用程序位于
    /usr/share/testApplication/bin/testApplication
    中。请尝试将其从shell中转储,并在这里写下在9000端口上运行应用程序时发生了什么,所以守护程序脚本中出现了一些错误。我把这里弄得一团糟。我使用
    Debian
    ,默认情况下它使用
    SystemV
    。在您的情况下-
    Ubuntu
    最好使用本系统默认的
    Upstart
    。这就是为什么
    service
    命令在Ubuntu上找不到脚本的原因。请在
    build.sbt
    中将
    SystemV
    切换到
    Upstart
    。如果您仍然有问题,请附加清单
    /etc/init/testApp
    -Dpidfile.path=/dev/null
    ,因为systemd通常会扮演此角色。
    import com.typesafe.sbt.packager.archetypes.ServerLoader.YourServiceManager
    
    packageArchetype.java_server
    
    serverLoading in Debian := YourServiceManager