由SystemD创建的sbt debian:packageBin安装脚本如何设置set应用程序写入PID /var/run或子目录的权限?
只有root拥有在/var/run中创建/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.pidconf/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管理自己的pid。。我无法让${{app_name}}扩展,所以我用硬编码的myWebApp代替了它。
sbt-本机-packager文档说pid应该放在/var/run/myWebApp中,日志应该放在/var/log/myWebApp中。
/var/run具有权限777与/run有775的符号链接;两者都属于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 docs在/var/run中放置pid的方式,但是这对我不起作用。
发布于 2015-08-30 15:16:40
下面是放置在debian.sbt中的解决方案
linuxPackageMappings += packageTemplateMapping(s"/var/run/${name.value}/")() withUser name.value withGroup name.value在conf/application.conf中不需要额外的条目。
https://stackoverflow.com/questions/32291788
复制相似问题