我正在使用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
答案 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并覆盖默认配置。
要升级,
[project root]/project/plugins.sbt
中,添加:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0")
[project root]/build.sbt
中,删除以下导入:
//import com.typesafe.sbt.SbtNativePackager._
//import NativePackagerKeys._
[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
希望它有所帮助。