]> Sergey Matveev's repositories - public-inbox.git/commitdiff
examples: systemd socket and service definitions for daemons
authorEric Wong <e@80x24.org>
Mon, 13 Jun 2016 04:53:30 +0000 (04:53 +0000)
committerEric Wong <e@80x24.org>
Mon, 13 Jun 2016 04:56:33 +0000 (04:56 +0000)
Since our daemons are built to take advantage of socket activation,
provide example files to allow systems administrators to hit the
ground running with systemd.

Example init files for other systems greatly appreciated.

examples/public-inbox-httpd.socket [new file with mode: 0644]
examples/public-inbox-httpd@.service [new file with mode: 0644]
examples/public-inbox-nntpd.socket [new file with mode: 0644]
examples/public-inbox-nntpd@.service [new file with mode: 0644]

diff --git a/examples/public-inbox-httpd.socket b/examples/public-inbox-httpd.socket
new file mode 100644 (file)
index 0000000..da37aec
--- /dev/null
@@ -0,0 +1,10 @@
+# ==> /etc/systemd/system/public-inbox-httpd.socket <==
+[Unit]
+Description = public-inbox-httpd socket
+
+[Socket]
+ListenStream = 127.0.0.1:280
+Service = public-inbox-httpd@1.service
+
+[Install]
+WantedBy = sockets.target
diff --git a/examples/public-inbox-httpd@.service b/examples/public-inbox-httpd@.service
new file mode 100644 (file)
index 0000000..3bb7072
--- /dev/null
@@ -0,0 +1,29 @@
+# ==> /etc/systemd/system/public-inbox-httpd@.service <==
+# Since SIGUSR2 upgrades do not work under systemd, this service file
+# allows starting two simultaneous services during upgrade time
+# (e.g. public-inbox-httpd@1 public-inbox-httpd@2) with the intention
+# that they take turns running in-between upgrades.  This should
+# allow upgrading without downtime.
+
+[Unit]
+Description = public-inbox PSGI server %i
+Wants = public-inbox-httpd.socket
+After = public-inbox-httpd.socket
+
+[Service]
+Environment = PI_CONFIG=/home/pi/.public-inbox/config \
+PATH=/usr/local/bin:/usr/bin:/bin \
+PERL_INLINE_DIRECTORY=/tmp/.pub-inline
+
+LimitNOFILE = 30000
+ExecStartPre = /bin/mkdir -p -m 1777 /tmp/.pub-inline
+ExecStart = /usr/local/bin/public-inbox-httpd
+Sockets = public-inbox-httpd.socket
+KillSignal = SIGQUIT
+User = nobody
+Group = nogroup
+ExecReload = /bin/kill -HUP $MAINPID
+TimeoutStopSec = 3600
+
+[Install]
+WantedBy = multi-user.target
diff --git a/examples/public-inbox-nntpd.socket b/examples/public-inbox-nntpd.socket
new file mode 100644 (file)
index 0000000..eeddf34
--- /dev/null
@@ -0,0 +1,10 @@
+# ==> /etc/systemd/system/public-inbox-nntpd.socket <==
+[Unit]
+Description = public-inbox-nntpd socket
+
+[Socket]
+ListenStream = 119
+Service = public-inbox-nntpd@1.service
+
+[Install]
+WantedBy = sockets.target
diff --git a/examples/public-inbox-nntpd@.service b/examples/public-inbox-nntpd@.service
new file mode 100644 (file)
index 0000000..078e920
--- /dev/null
@@ -0,0 +1,31 @@
+# ==> /etc/systemd/system/public-inbox-nntpd@.service <==
+# Since SIGUSR2 upgrades do not work under systemd, this service file
+# allows starting two simultaneous services during upgrade time
+# (e.g. public-inbox-nntpd@1 public-inbox-nntpd@2) with the intention
+# that they take turns running in-between upgrades.  This should
+# allow upgrading without downtime.
+
+[Unit]
+Description = public-inbox NNTP server %i
+Wants = public-inbox-nntpd.socket
+After = public-inbox-nntpd.socket
+
+[Service]
+Environment = PI_CONFIG=/home/pi/.public-inbox/config \
+PATH=/usr/local/bin:/usr/bin:/bin \
+PERL_INLINE_DIRECTORY=/tmp/.pub-inline
+
+LimitNOFILE = 30000
+ExecStartPre = /bin/mkdir -p -m 1777 /tmp/.pub-inline
+ExecStart = /usr/local/bin/public-inbox-nntpd \
+-1 /var/log/public-inbox/nntpd.out.log \
+-2 /var/log/public-inbox/nntpd.err.log
+Sockets = public-inbox-nntpd.socket
+KillSignal = SIGQUIT
+User = nobody
+Group = nogroup
+ExecReload = /bin/kill -HUP $MAINPID
+TimeoutStopSec = 3600
+
+[Install]
+WantedBy = multi-user.target