PID file fixes (systemd, openrc)
pavel committed
Apr 9, 2016 at 04:55 UTC
bc443e594fe0faf597d690c9f8c03aefaae35a84
3 files changed
+6
-1
src/daemon.c
+1
@@ -306,6 +306,7 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
306
// don't close it, we might need it at exit
307
// close(pidfd);
308
}
309
+ else error("Failed to open pidfile '%s'.", pidfile);
310
}
311
312
if(user && *user) {
system/netdata-openrc.in
+5
@@ -36,6 +36,11 @@ depend() {
36
checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/cache/netdata /run/netdata
37
}
38
39
+start_pre() {
40
+ piddir=$(dirname ${pidfile})
41
+ mkdir -p ${piddir}
42
+}
43
+
44
start_post() {
45
if [[ ! -f @sysconfdir_POST@/netdata/netdata.conf ]]; then
46
ebegin "Downloading default configuration to @sysconfdir_POST@/netdata/netdata.conf"
system/netdata.service.in
-1
@@ -9,7 +9,6 @@ User=root
9
Group=root
10
PIDFile=@localstatedir_POST@/run/netdata/netdata.pid
11
ExecStartPre=/usr/bin/mkdir -p @localstatedir_POST@/run/netdata
12
-ExecStartPre=/usr/bin/chown -R netdata:netdata @localstatedir_POST@/run/netdata
12
ExecStart=@sbindir_POST@/netdata -pidfile @localstatedir_POST@/run/netdata/netdata.pid
13
ExecStop=/bin/kill -SIGTERM $MAINPID
14
TimeoutStopSec=30