diff options
-rw-r--r-- | system/netdata-freebsd.in | 5 | ||||
-rw-r--r-- | system/netdata-init-d.in | 4 | ||||
-rw-r--r-- | system/netdata-lsb.in | 7 | ||||
-rw-r--r-- | system/netdata.service.in | 4 |
4 files changed, 17 insertions, 3 deletions
diff --git a/system/netdata-freebsd.in b/system/netdata-freebsd.in index 15e858b8e8..501a8c697c 100644 --- a/system/netdata-freebsd.in +++ b/system/netdata-freebsd.in @@ -6,7 +6,8 @@ name=netdata rcvar=netdata_enable -pidfile="@localstatedir_POST@/run/netdata.pid" +piddir="@localstatedir_POST@/run/netdata" +pidfile="${pidfile}/netdata.pid" command="@sbindir_POST@/netdata" command_args="-P ${pidfile}" @@ -23,11 +24,13 @@ savedb_cmd="netdata_savedb" netdata_prestart() { + [ ! -d "${piddir}" ] && mkdir -p "${piddir}" return 0 } netdata_poststop() { + rm "${pidfile}" return 0 } diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in index ae60098368..332c80639b 100644 --- a/system/netdata-init-d.in +++ b/system/netdata-init-d.in @@ -14,7 +14,8 @@ DAEMON="netdata" DAEMON_PATH=@sbindir_POST@ -PIDFILE=@localstatedir_POST@/run/$DAEMON.pid +PIDFILE_PATH=@localstatedir_POST@/run/netdata +PIDFILE=$PIDFILE_PATH/$DAEMON.pid DAEMONOPTS="-P $PIDFILE" STOP_TIMEOUT="60" @@ -25,6 +26,7 @@ LOCKFILE=/var/lock/subsys/$DAEMON service_start() { [ -x $DAEMON_PATH ] || exit 5 + [ ! -d $PIDFILE_PATH ] && mkdir -p $PIDFILE_PATH echo -n "Starting $DAEMON..." daemon $DAEMON_PATH/$DAEMON $DAEMONOPTS RETVAL=$? diff --git a/system/netdata-lsb.in b/system/netdata-lsb.in index eb6a68404d..37cf095d63 100644 --- a/system/netdata-lsb.in +++ b/system/netdata-lsb.in @@ -20,7 +20,8 @@ ${DEBIAN_SCRIPT_DEBUG:+ set -v -x} DAEMON="netdata" DAEMON_PATH=@sbindir_POST@ -PIDFILE=@localstatedir_POST@/run/$DAEMON.pid +PIDFILE_PATH=@localstatedir_POST@/run/netdata +PIDFILE=$PIDFILE_PATH/$DAEMON.pid DAEMONOPTS="-P $PIDFILE" test -x $DAEMON_PATH/$DAEMON || exit 0 @@ -32,6 +33,10 @@ cd / umask 022 service_start() { + if [ ! -d $PIDFILE_PATH ]; then + mkdir -p $PIDFILE_PATH + fi + log_daemon_msg "Starting real-time performance monitoring" "netdata" start_daemon -p $PIDFILE $DAEMON_PATH/$DAEMON $DAEMONOPTS RETVAL=$? diff --git a/system/netdata.service.in b/system/netdata.service.in index 7b716b3b25..7b94b7eea5 100644 --- a/system/netdata.service.in +++ b/system/netdata.service.in @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-3.0+ [Unit] Description=Real time performance monitoring + +# append here other services you want netdata to wait for them to start After=network.target httpd.service squid.service nfs-server.service mysqld.service mysql.service named.service postfix.service chronyd.service [Service] @@ -9,9 +11,11 @@ User=netdata Group=netdata RuntimeDirectory=netdata RuntimeDirectoryMode=0775 +PIDFile=@localstatedir_POST@/run/netdata/netdata.pid ExecStart=@sbindir_POST@/netdata -P @localstatedir_POST@/run/netdata/netdata.pid -D -W set global 'process scheduling policy' 'keep' -W set global 'OOM score' 'keep' ExecStartPre=/bin/mkdir -p @localstatedir_POST@/cache/netdata ExecStartPre=/bin/chown -R netdata:netdata @localstatedir_POST@/cache/netdata +ExecStopPost=[ -f @localstatedir_POST@/run/netdata/netdata.pid ] && rm @localstatedir_POST@/run/netdata/netdata.pid PermissionsStartOnly=true # saving a big db on slow disks may need some time |