Merge pull request #814 from mfournier/upstart-systemd-examples
authorPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 19 Nov 2014 16:02:11 +0000 (17:02 +0100)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 19 Nov 2014 16:02:11 +0000 (17:02 +0100)
upstart and systemd doc & examples

contrib/systemd.collectd.service [new file with mode: 0644]
contrib/upstart.collectd.conf
src/collectd.pod

diff --git a/contrib/systemd.collectd.service b/contrib/systemd.collectd.service
new file mode 100644 (file)
index 0000000..b046192
--- /dev/null
@@ -0,0 +1,23 @@
+[Unit]
+Description=Collectd
+After=local-fs.target network.target
+Requires=local-fs.target network.target
+
+[Service]
+ExecStart=/usr/sbin/collectd
+
+# Tell systemd it will receive a notification from collectd over it's control
+# socket once the daemon is ready. See systemd.service(5) for more details.
+Type=notify
+NotifyAccess=main
+
+# Restart the collectd daemon after a 10 seconds delay, in case it crashes.
+Restart=always
+RestartSec=10
+
+# Send all console messages to syslog.
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
index c175ee6..69032a5 100644 (file)
@@ -20,6 +20,7 @@ stop on runlevel [!2345]
 # these cannot be started at boot time by the system without
 # arcane trickery. Also a root user will not see these tasks/jobs
 # by default. set*id is a reasonable and secure compromise.
+# These options are not supported on early upstart versions.
 #setuid nobody
 #setgid nobody
 
@@ -31,15 +32,17 @@ stop on runlevel [!2345]
 # shell commands via `sh -e`.
 env DAEMON=/usr/sbin/collectd
 
-# Tell upstart to watch for forking when tracking the pid for us.
+# Tell upstart to wait for collectd to SIGSTOP itself, signaling it is ready
+# to run.
 expect stop
 
 # prevent thrashing - 10 restarts in 5 seconds
 respawn
 respawn limit 10 5
 
-# Make a log available in /var/log/upstart/collectd.log
-console log
+# Uncomment to make a log available in /var/log/upstart/collectd.log
+# (not supported on early upstart versions).
+#console log
 
 # The daemon will not start if the configuration is invalid.
 pre-start exec $DAEMON -t
index 8fccdb3..fb0403b 100644 (file)
@@ -49,7 +49,11 @@ config-option.
 
 Don't fork to the background. I<collectd> will also B<not> close standard file
 descriptors, detach from the session nor write a pid file. This is mainly
-thought for 'supervising' init replacements such as I<runit>.
+thought for 'supervising' init replacements such as I<runit>. If using
+I<upstart> or I<systemd> though, starting with version 5.5.0 I<collectd> is
+able to notify these two init replacements, and B<does> require forking to the
+background for process supervision. The F<contrib/> directory has sample
+I<upstart> and I<systemd> configuration files.
 
 =item B<-h>