I have created a little application using the Play 2 Framework and tried to generate a RPM package for deployment to a centos server from this. I have added the current version of the sbt-native-packager to my plugins.sbt:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.1")
In my build.sbt I put the following:
packageArchetype.java_server
packageDescription := "Custom application configuration"
maintainer in Linux := "Sönke"
packageSummary in Linux := "Ansible Callback Server"
rpmVendor in Rpm := "Sönke"
rpmLicense in Rpm := Some("BSD")
And then I ran activator rpm:packageBin which produced a valid rpm package that I was able to install.
Problem now is, when I just start the program directly from the command line everything works fine, but when I do a service start to get it running in the background it fails.
After spending some time looking at strace output I think the problem is in the following lines:
8843 <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], WSTOPPED, NULL) = 8845
8843 socket(PF_NETLINK, SOCK_RAW, 9) = 4
8843 fcntl(4, F_SETFD, FD_CLOEXEC) = 0
8843 readlink("/proc/self/exe", "/sbin/runuser", 4096) = 13
8843 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3df6d5d0) = -1 ENOTTY (Inappropriate ioctl for device)
8843 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3df6d5d0) = -1 ENOTTY (Inappropriate ioctl for device)
8843 ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3df6d5d0) = -1 ENOTTY (Inappropriate ioctl for device)
8843 sendto(4, "p\0\0\0P\4\5\0\3\0\0\0\0\0\0\0op=PAM:setcred a"..., 112, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 112
8843 poll([{fd=4, events=POLLIN}], 1, 500) = 1 ([{fd=4, revents=POLLIN}])
8843 recvfrom(4, "$\0\0\0\2\0\0\0\3\0\0\0\213\"\0\0\0\0\0\0p\0\0\0P\4\5\0\3\0\0\0"..., 8988, MSG_PEEK|MSG_DONTWAIT, {sa_family=AF_NETLINK, pid=0, groups=00000000}, [12]) = 36
8843 recvfrom(4, "$\0\0\0\2\0\0\0\3\0\0\0\213\"\0\0\0\0\0\0p\0\0\0P\4\5\0\3\0\0\0"..., 8988, MSG_DONTWAIT, {sa_family=AF_NETLINK, pid=0, groups=00000000}, [12]) = 36
8843 close(4) = 0
8843 getuid() = 0
8843 sendto(3, "<86>Jun 14 13:41:01 runuser: pam"..., 92, MSG_NOSIGNAL, NULL, 0) = 92
8843 socket(PF_NETLINK, SOCK_RAW, 9) = 4
8843 fcntl(4, F_SETFD, FD_CLOEXEC) = 0
8843 readlink("/proc/self/exe", "/sbin/runuser", 4096) = 13
8843 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3df6d5d0) = -1 ENOTTY (Inappropriate ioctl for device)
8843 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3df6d5d0) = -1 ENOTTY (Inappropriate ioctl for device)
8843 ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3df6d5d0) = -1 ENOTTY (Inappropriate ioctl for device)
8843 sendto(4, "x\0\0\0R\4\5\0\4\0\0\0\0\0\0\0op=PAM:session_c"..., 120, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 120
8843 poll([{fd=4, events=POLLIN}], 1, 500) = 1 ([{fd=4, revents=POLLIN}])
8843 recvfrom(4, "$\0\0\0\2\0\0\0\4\0\0\0\213\"\0\0\0\0\0\0x\0\0\0R\4\5\0\4\0\0\0"..., 8988, MSG_PEEK|MSG_DONTWAIT, {sa_family=AF_NETLINK, pid=0, groups=00000000}, [12]) = 36
8843 recvfrom(4, "$\0\0\0\2\0\0\0\4\0\0\0\213\"\0\0\0\0\0\0x\0\0\0R\4\5\0\4\0\0\0"..., 8988, MSG_DONTWAIT, {sa_family=AF_NETLINK, pid=0, groups=00000000}, [12]) = 36
8843 close(4) = 0
From my (limited) understanding, the program seems to try and do something here that requires a tty, but since it is running without one this fails and the process then exits. I have searched the github issues and googled a bit, but can't seem to find anything on this, which suggests to me that I am doing something wrong here, but I am out of ideas what exactly that might be.
Apparantly the issue is, that play applications create a pid file of their own, which as a default is in the working directory, which creates issues.
The solution is to uncomment the following line in /etc/default/{progname}
-Dpidfile.path=/var/run/provisionist/play.pid
which I was too stupid to find.