summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAmish <3330468+amishmm@users.noreply.github.com>2020-01-30 03:45:32 +0530
committerGitHub <noreply@github.com>2020-01-30 08:15:32 +1000
commit2979efe03161499e9a53f76d843c2fd7e5006a92 (patch)
treefdb94096c30a18fa6405a1c8e44f18db2395ad12 /system
parentf5a043ce21642a68c7bef7363163d308edd97074 (diff)
Better systemd service file (#7790)
* Provide a new service file for systemd v235+ Let systemd create directories, instead of via ExecStartPre. * Do not set global options in service file via -W option. The default set by service file are anyway the defaults used by netdata. Better place is to mention them in netdata.conf and allow user to change those options via netdata.conf file instead of changing in service file.
Diffstat (limited to 'system')
-rw-r--r--system/netdata.conf4
-rw-r--r--system/netdata.service.in2
-rw-r--r--system/netdata.service.v235.in48
3 files changed, 53 insertions, 1 deletions
diff --git a/system/netdata.conf b/system/netdata.conf
index 7d7c54f420..b3c2b2c68f 100644
--- a/system/netdata.conf
+++ b/system/netdata.conf
@@ -19,6 +19,10 @@
# by default do not expose the netdata port
bind to = localhost
+ # some defaults to run netdata with least priority
+ process scheduling policy = idle
+ OOM score = 1000
+
[web]
web files owner = root
web files group = netdata
diff --git a/system/netdata.service.in b/system/netdata.service.in
index dd0ee3cca9..3abb16460c 100644
--- a/system/netdata.service.in
+++ b/system/netdata.service.in
@@ -12,7 +12,7 @@ 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'
+ExecStart=@sbindir_POST@/netdata -P @localstatedir_POST@/run/netdata/netdata.pid -D
ExecStartPre=/bin/mkdir -p @localstatedir_POST@/cache/netdata
ExecStartPre=/bin/chown -R netdata:netdata @localstatedir_POST@/cache/netdata
ExecStartPre=/bin/mkdir -p @localstatedir_POST@/run/netdata
diff --git a/system/netdata.service.v235.in b/system/netdata.service.v235.in
new file mode 100644
index 0000000000..303acb17c1
--- /dev/null
+++ b/system/netdata.service.v235.in
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+[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]
+Type=simple
+User=netdata
+Group=netdata
+RuntimeDirectory=netdata
+CacheDirectory=netdata
+StateDirectory=netdata
+LogsDirectory=netdata
+RuntimeDirectoryMode=0775
+StateDirectoryMode=0750
+CacheDirectoryMode=0750
+LogsDirectoryMode=0750
+PIDFile=netdata/netdata.pid
+ExecStart=@sbindir_POST@/netdata -P $PIDFILE -D
+
+# saving a big db on slow disks may need some time
+TimeoutStopSec=60
+
+# restart netdata if it crashes
+Restart=on-failure
+RestartSec=30
+
+# The minimum netdata Out-Of-Memory (OOM) score.
+# netdata (via [global].OOM score in netdata.conf) can only increase the value set here.
+# To decrease it, set the minimum here and set the same or a higher value in netdata.conf.
+# Valid values: -1000 (never kill netdata) to 1000 (always kill netdata).
+OOMScoreAdjust=1000
+
+# Valid policies: other (the system default) | batch | idle | fifo | rr
+# To give netdata the max priority, set CPUSchedulingPolicy=rr and CPUSchedulingPriority=99
+CPUSchedulingPolicy=idle
+
+# This sets the scheduling priority (for policies: rr and fifo).
+# Priority gets values 1 (lowest) to 99 (highest).
+#CPUSchedulingPriority=1
+
+# For scheduling policy 'other' and 'batch', this sets the lowest niceness of netdata (-20 highest to 19 lowest).
+#Nice=0
+
+[Install]
+WantedBy=multi-user.target