sbt debian:packageBin
创建的SystemD安装脚本如何设置webapp的权限以写入PID /var/run
或子目录?
只有root有权在pid
中创建/var/run
文件或创建包含/var/run/myWebApp/
文件的pid
目录。 debian:packageBin
任务使webapp作为从webapp名称创建的特殊user:group
运行。如果创建的目录与/var/run/myWebApp
类似,则myWebApp
组需要写入权限,但我看不到任何方法可以自动执行此操作。我错过了什么吗?
以下是我的一些配置文件:
dist/conf/application.ini
:
-Dpidfile.path=/var/run/webapp2/webapp2.pid
conf/application.conf
:
# This seems redundant ... should it be removed?
pidfile.path = /var/run/webapp2/pid
pidfile.path = ${?pidfile.path}
debian.sbt
:
import com.typesafe.sbt.packager.archetypes.ServerLoader.{Systemd, SystemV, Upstart}
import com.typesafe.sbt.SbtNativePackager.autoImport._
lazy val root = (project in file(".")).enablePlugins(PlayScala, DebianPlugin)
enablePlugins(JavaAppPackaging)
enablePlugins(JDebPackaging)
enablePlugins(JavaServerAppPackaging)
serverLoading in Debian := Systemd
maintainer in Linux := "Mike Slinn <mslinn@mslinn.com>"
packageSummary in Linux := "myWebApp blah blah"
packageDescription := "myWebApp blah blah"
daemonUser in Linux := normalizedName.value // user which will execute the application, resolves to "myWebApp"
daemonGroup in Linux := (daemonUser in Linux).value // group which will execute the application, resolves to "myWebApp"
更新
Play manages its own pid.。我无法展开${{app_name}}
,因此我改为编码myWebApp
。
sbt-native-packager docs表示应将pid放在/var/run/myWebApp
中,将日志放在/var/log/myWebApp
中。
/var/run
有权限777通过权限775符号链接到/run
;两者都归root:root
所有。因此,非root进程可以写入/var/run
的唯一方法是在/var/run
下使用适当的权限创建目录。例如,postgres:postgres
有权写入/var/run/postgres
:
$ ls -adlF /var/run/postgresql
drwxrwsr-x 3 postgres postgres 120 Aug 28 01:17 /var/run/postgresql/
这就是Play文档显示如何将pid放入/var/run
应该有效,但这对我不起作用。
答案 0 :(得分:0)
以下是解决方案,放在debian.sbt
:
linuxPackageMappings += packageTemplateMapping(s"/var/run/${name.value}/")() withUser name.value withGroup name.value
conf/application.conf
中无需额外的条目。