summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/dinit/netdata.in11
-rwxr-xr-xsystem/install-service.sh.in61
-rw-r--r--system/lsb/init.d/netdata.in16
-rw-r--r--system/systemd/journald@netdata.conf5
-rw-r--r--system/systemd/netdata.service.in3
-rw-r--r--system/systemd/netdata.service.v235.in3
6 files changed, 91 insertions, 8 deletions
diff --git a/system/dinit/netdata.in b/system/dinit/netdata.in
new file mode 100644
index 000000000..607df4520
--- /dev/null
+++ b/system/dinit/netdata.in
@@ -0,0 +1,11 @@
+# dinit service description for Netdata
+#
+# Currently only properly tested on Chimera Linux.
+
+type = bgprocess
+command = @sbindir_POST@/netdata -P @localstatedir_POST@/run/netdata.pid -D
+pid-file = @localstatedir_POST@/run/netdata.pid
+options = signal-process-only
+load-options = export-passwd-vars
+depends-on = early-fs-local.target
+after = network.target
diff --git a/system/install-service.sh.in b/system/install-service.sh.in
index 226dca5de..0ed4fa1bb 100755
--- a/system/install-service.sh.in
+++ b/system/install-service.sh.in
@@ -29,7 +29,7 @@ DUMP_CMDS=0
ENABLE="auto"
EXPORT_CMDS=0
INSTALL=1
-LINUX_INIT_TYPES="systemd openrc lsb initd runit"
+LINUX_INIT_TYPES="systemd openrc lsb initd runit dinit"
PLATFORM="$(uname -s)"
SHOW_SVC_TYPE=0
SVC_SOURCE="@libsysdir_POST@"
@@ -563,6 +563,65 @@ runit_cmds() {
}
# =====================================================================
+# dinit support functions
+
+_check_dinit() {
+ # if /etc/dinit.d does not exist, it’s not dinit
+ [ ! -d /etc/dinit.d ] && echo "NO" && return 0
+
+ # if PID 1 is dinit, it’s dinit
+ [ "$(basename "$(readlink /proc/1/exe)" 2> /dev/null)" = "dinit" ] && echo "YES" && return 0
+
+ # if /run/dinitctl exists and is a socket, it’s dinit
+ [ -S /run/dinitctl ] && echo "YES" && return 0
+
+ # if the dinitctl command exists despite getting to this point, it’s dinit, but not booted as such
+ [ -n "$(command -v dinitctl 2>/dev/null || true)" ] && echo "OFFLINE" && return 0
+
+ echo "NO" && return 0
+}
+
+check_dinit() {
+ if [ -z "${IS_DINIT}" ]; then
+ IS_DINIT="$(_check_dinit)"
+ fi
+
+ echo "${IS_DINIT}"
+}
+
+_run_dinitctl() {
+ opts=''
+
+ if [ "$(check_dinit)" = "OFFLINE" ]; then
+ opts="-o"
+ fi
+
+ # shellcheck disable=SC2086
+ dinitctl ${opts} "${@}"
+}
+
+enable_dinit() {
+ _run_dinitctl enable netdata
+}
+
+enable_dinit() {
+ _run_dinitctl disable netdata
+}
+
+install_dinit_service() {
+ install_generic_service dinit/netdata "dinit" /etc/dinit.d enable_dinit disable_dinit
+}
+
+dinit_cmds() {
+ if [ "$(check_dinit)" = "YES" ]; then
+ NETDATA_START_CMD='dinitctl start netdata'
+ NETDATA_STOP_CMD='dinitct stop netdata'
+ else # Not booted using dinit, use external defaults by not providing commands.
+ warning "Detected dinit, but the system is not booted using dinit. Unable to provide commands to start or stop Netdata using the service manager."
+ fi
+}
+
+# =====================================================================
# WSL support functions
_check_wsl() {
diff --git a/system/lsb/init.d/netdata.in b/system/lsb/init.d/netdata.in
index e429ad1c9..2c6ac7f43 100644
--- a/system/lsb/init.d/netdata.in
+++ b/system/lsb/init.d/netdata.in
@@ -47,18 +47,24 @@ service_start() {
chown @netdata_user_POST@:@netdata_user_POST@ $PIDFILE_PATH
- log_daemon_msg "Starting real-time performance monitoring" "netdata"
+ log_success_msg "Starting real-time performance monitoring"
start_daemon -p $PIDFILE $DAEMON_PATH/$DAEMON $DAEMONOPTS
RETVAL=$?
- log_end_msg $RETVAL
+ case "${RETVAL}" in
+ 0) log_success_msg "Started real-time performance monitoring" ;;
+ *) log_error_msg "Failed to start real-time performance monitoring" ;;
+ esac
return $RETVAL
}
service_stop() {
- log_daemon_msg "Stopping real-time performance monitoring" "netdata"
+ log_success_msg "Stopping real-time performance monitoring"
killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON
RETVAL=$?
- log_end_msg $RETVAL
+ case "${RETVAL}" in
+ 0) log_success_msg "Stopped real-time performance monitoring" ;;
+ *) log_error_msg "Failed to stop real-time performance monitoring" ;;
+ esac
if [ $RETVAL -eq 0 ]; then
rm -f ${PIDFILE}
@@ -77,7 +83,7 @@ condrestart() {
}
service_status() {
- status_of_proc -p $PIDFILE $DAEMON_PATH/$DAEMON netdata
+ pidofproc -p $PIDFILE $DAEMON_PATH/$DAEMON
}
diff --git a/system/systemd/journald@netdata.conf b/system/systemd/journald@netdata.conf
new file mode 100644
index 000000000..28fdca266
--- /dev/null
+++ b/system/systemd/journald@netdata.conf
@@ -0,0 +1,5 @@
+# See journald.conf(5) for details.
+
+[Journal]
+SystemMaxUse=256M
+RuntimeMaxUse=64M
diff --git a/system/systemd/netdata.service.in b/system/systemd/netdata.service.in
index 7d15dad77..3ea1f9d8e 100644
--- a/system/systemd/netdata.service.in
+++ b/system/systemd/netdata.service.in
@@ -3,7 +3,8 @@
Description=Real time performance monitoring
# append here other services you want netdata to wait for them to start
-After=network.target
+After=network.target network-online.target nss-lookup.target
+Wants=network-online.target nss-lookup.target
[Service]
LogNamespace=netdata
diff --git a/system/systemd/netdata.service.v235.in b/system/systemd/netdata.service.v235.in
index 06f03b269..e2878407b 100644
--- a/system/systemd/netdata.service.v235.in
+++ b/system/systemd/netdata.service.v235.in
@@ -3,7 +3,8 @@
Description=Real time performance monitoring
# append here other services you want netdata to wait for them to start
-After=network.target
+After=network.target network-online.target nss-lookup.target
+Wants=network-online.target nss-lookup.target
[Service]
LogNamespace=netdata