mirror of
https://github.com/netdata/netdata.git
synced 2025-04-07 06:45:39 +00:00
Add experimental support for running under runit. (#13841)
* Add basic runit service script for Netdata. * Integrate runit handling in install-service script. * Add new runit script to .gitignore. * Fix service file installation. We need to ensure the service directory actually gets created, and thus need to use `-D` with the `install` command. * Sync with system restructure. * Fix botched update to Makefile.am.
This commit is contained in:
parent
4857259197
commit
2597f4f035
5 changed files with 75 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -123,6 +123,7 @@ system/initd/init.d/netdata
|
|||
system/launchd/netdata.plist
|
||||
system/lsb/init.d/netdata
|
||||
system/openrc/init.d/netdata
|
||||
system/runit/run
|
||||
system/systemd/netdata.service
|
||||
system/systemd/netdata.service.*
|
||||
system/systemd/netdata-updater.service
|
||||
|
|
|
@ -1060,7 +1060,7 @@ fi
|
|||
# -----------------------------------------------------------------------------
|
||||
progress "Fix generated files permissions"
|
||||
|
||||
run chmod 755 ./system/*/init.d/netdata ./system/*/rc.d/netdata ./system/install-service.sh
|
||||
run chmod 755 ./system/*/init.d/netdata ./system/*/rc.d/netdata ./system/runit/run ./system/install-service.sh
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
progress "Creating standard user and groups for netdata"
|
||||
|
|
|
@ -11,6 +11,7 @@ CLEANFILES = \
|
|||
lsb/init.d/netdata \
|
||||
openrc/conf.d/netdata \
|
||||
openrc/init.d/netdata \
|
||||
runit/run \
|
||||
systemd/netdata.service \
|
||||
systemd/netdata.service.v235 \
|
||||
systemd/netdata-updater.service \
|
||||
|
@ -40,6 +41,7 @@ libsyslsbinitddir=$(libsyslsbdir)/init.d
|
|||
libsysopenrcdir=$(libsysdir)/openrc
|
||||
libsysopenrcinitddir=$(libsysopenrcdir)/init.d
|
||||
libsysopenrcconfddir=$(libsysopenrcdir)/conf.d
|
||||
libsysrunitdir=$(libsysdir)/runit
|
||||
libsyssystemddir=$(libsysdir)/systemd
|
||||
|
||||
# Explicitly install directories to avoid permission issues due to umask
|
||||
|
@ -55,6 +57,7 @@ install-exec-local:
|
|||
$(INSTALL) -d $(DESTDIR)$(libsyssystemddir)
|
||||
$(INSTALL) -d $(DESTDIR)$(libsysopenrcinitddir)
|
||||
$(INSTALL) -d $(DESTDIR)$(libsysopenrcconfddir)
|
||||
$(INSTALL) -d $(DESTDIR)$(libsysrunitdir)
|
||||
$(INSTALL) -d $(DESTDIR)$(libconfigvnodesdir)
|
||||
|
||||
dist_libconfigvnodes_DATA = \
|
||||
|
@ -98,6 +101,10 @@ nodist_libsysopenrcconfd_DATA = \
|
|||
openrc/conf.d/netdata \
|
||||
$(NULL)
|
||||
|
||||
nodist_libsysrunit_DATA = \
|
||||
runit/run \
|
||||
$(NULL)
|
||||
|
||||
nodist_libsyssystemd_DATA = \
|
||||
systemd/netdata.service \
|
||||
systemd/netdata.service.v235 \
|
||||
|
@ -119,6 +126,7 @@ dist_noinst_DATA = \
|
|||
lsb/init.d/netdata.in \
|
||||
openrc/conf.d/netdata.in \
|
||||
openrc/init.d/netdata.in \
|
||||
runit/run.in \
|
||||
systemd/netdata.service.in \
|
||||
systemd/netdata.service.v235.in \
|
||||
systemd/netdata-updater.service.in \
|
||||
|
|
|
@ -87,7 +87,7 @@ get_os_key() {
|
|||
valid_types() {
|
||||
case "${PLATFORM}" in
|
||||
Linux)
|
||||
echo "detect systemd openrc lsb initd"
|
||||
echo "detect ${LINUX_INIT_TYPES}"
|
||||
;;
|
||||
FreeBSD)
|
||||
echo "detect freebsd"
|
||||
|
@ -475,8 +475,6 @@ initd_cmds() {
|
|||
|
||||
# =====================================================================
|
||||
# runit support functions
|
||||
#
|
||||
# Currently not supported, this exists to provide useful error messages.
|
||||
|
||||
_check_runit() {
|
||||
# if there is no runsvdir command, then it's not runit
|
||||
|
@ -503,19 +501,61 @@ check_runit() {
|
|||
}
|
||||
|
||||
install_runit_service() {
|
||||
error "Detected runit, which we do not currently support."
|
||||
exit 3
|
||||
if [ -d /etc/sv ]; then
|
||||
svc_dir="/etc/sv/netdata"
|
||||
elif [ -d /etc/runit/sv ]; then
|
||||
svc_dir="/etc/runit/sv/netdata"
|
||||
else
|
||||
error "Failed to locate service directory"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ -d /service ]; then
|
||||
live_svc_dir="/service"
|
||||
elif [ -d /var/service ]; then
|
||||
live_svc_dir="/var/service"
|
||||
elif [ -d /run/runit/service ]; then
|
||||
live_svc_dir="/run/runit/service"
|
||||
elif [ -d /etc/runit/runsvdir/default ]; then
|
||||
live_svc_dir="/etc/runit/runsvdir/default"
|
||||
else
|
||||
error "Failed to locate live service directory"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
svc_file="${svc_dir}/run"
|
||||
|
||||
info "Installing runit service file."
|
||||
if [ ! -f "${svc_file}" ] && [ "${ENABLE}" = "auto" ]; then
|
||||
ENABLE="enable"
|
||||
fi
|
||||
|
||||
if ! install -D -p -m 0755 -o 0 -g 0 "${SVC_SOURCE}/runit/run" "${svc_file}"; then
|
||||
error "Failed to install service file."
|
||||
exit 4
|
||||
fi
|
||||
|
||||
case ${ENABLE} in
|
||||
enable)
|
||||
if ! ln -s "${svc_dir}" "${live_svc_dir}"; then
|
||||
warning "Failed to enable the Netdata service."
|
||||
fi
|
||||
;;
|
||||
disable)
|
||||
if ! rm "${live_svc_dir}/netdata"; then
|
||||
warning "Failed to disable the Netdata service."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
runit_cmds() {
|
||||
error "Detected runit, which we do not currently support."
|
||||
exit 3
|
||||
NETDATA_START_CMD="sv start netdata"
|
||||
NETDATA_STOP_CMD="sv stop netdata"
|
||||
}
|
||||
|
||||
# =====================================================================
|
||||
# WSL support functions
|
||||
#
|
||||
# Cannot be supported, this exists to provide useful error messages.
|
||||
|
||||
_check_wsl() {
|
||||
# If uname -r contains the string WSL, then it's WSL.
|
||||
|
|
16
system/runit/run.in
Normal file
16
system/runit/run.in
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
piddir="@localstatedir_POST@/run/netdata/netdata.pid"
|
||||
pidfile="${piddir}/netdata.pid"
|
||||
|
||||
cachedir="@localstatedir_POST@/cache/netdata"
|
||||
|
||||
command="@sbindir_POST@/netdata"
|
||||
command_args="-P ${pidfile} -D"
|
||||
|
||||
[ ! -d "${piddir}" ] && mkdir -p "${piddir}"
|
||||
[ ! -d "${cachedir}" ] && mkdir -p "${cachedir}"
|
||||
chown -R @netdata_user_POST@ "${piddir}"
|
||||
chown -R @netdata_user_POST@ "${cachedir}"
|
||||
|
||||
exec ${command} ${command_args}
|
Loading…
Add table
Reference in a new issue