@cryptotaxi247 / netdata-1 / commits / 2979efe03

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.

Amish committed Jan 30, 2020 at 03:45 UTC 2979efe03161499e9a53f76d843c2fd7e5006a92
3 files changed +53 -1
system/netdata.conf
+4
@@ -19,6 +19,10 @@
19 # by default do not expose the netdata port
20 bind to = localhost
21
22 + # some defaults to run netdata with least priority
23 + process scheduling policy = idle
24 + OOM score = 1000
25 +
26 [web]
27 web files owner = root
28 web files group = netdata
system/netdata.service.in
+1 -1
@@ -12,7 +12,7 @@ Group=netdata
12 RuntimeDirectory=netdata
13 RuntimeDirectoryMode=0775
14 PIDFile=@localstatedir_POST@/run/netdata/netdata.pid
15 -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'
15 +ExecStart=@sbindir_POST@/netdata -P @localstatedir_POST@/run/netdata/netdata.pid -D
16 ExecStartPre=/bin/mkdir -p @localstatedir_POST@/cache/netdata
17 ExecStartPre=/bin/chown -R netdata:netdata @localstatedir_POST@/cache/netdata
18 ExecStartPre=/bin/mkdir -p @localstatedir_POST@/run/netdata
system/netdata.service.v235.in new
+48
@@ -0,0 +1,48 @@
1 +# SPDX-License-Identifier: GPL-3.0-or-later
2 +[Unit]
3 +Description=Real time performance monitoring
4 +
5 +# append here other services you want netdata to wait for them to start
6 +After=network.target httpd.service squid.service nfs-server.service mysqld.service mysql.service named.service postfix.service chronyd.service
7 +
8 +[Service]
9 +Type=simple
10 +User=netdata
11 +Group=netdata
12 +RuntimeDirectory=netdata
13 +CacheDirectory=netdata
14 +StateDirectory=netdata
15 +LogsDirectory=netdata
16 +RuntimeDirectoryMode=0775
17 +StateDirectoryMode=0750
18 +CacheDirectoryMode=0750
19 +LogsDirectoryMode=0750
20 +PIDFile=netdata/netdata.pid
21 +ExecStart=@sbindir_POST@/netdata -P $PIDFILE -D
22 +
23 +# saving a big db on slow disks may need some time
24 +TimeoutStopSec=60
25 +
26 +# restart netdata if it crashes
27 +Restart=on-failure
28 +RestartSec=30
29 +
30 +# The minimum netdata Out-Of-Memory (OOM) score.
31 +# netdata (via [global].OOM score in netdata.conf) can only increase the value set here.
32 +# To decrease it, set the minimum here and set the same or a higher value in netdata.conf.
33 +# Valid values: -1000 (never kill netdata) to 1000 (always kill netdata).
34 +OOMScoreAdjust=1000
35 +
36 +# Valid policies: other (the system default) | batch | idle | fifo | rr
37 +# To give netdata the max priority, set CPUSchedulingPolicy=rr and CPUSchedulingPriority=99
38 +CPUSchedulingPolicy=idle
39 +
40 +# This sets the scheduling priority (for policies: rr and fifo).
41 +# Priority gets values 1 (lowest) to 99 (highest).
42 +#CPUSchedulingPriority=1
43 +
44 +# For scheduling policy 'other' and 'batch', this sets the lowest niceness of netdata (-20 highest to 19 lowest).
45 +#Nice=0
46 +
47 +[Install]
48 +WantedBy=multi-user.target