user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] examples: systemd socket and service definitions for daemons
@ 2016-06-13 21:38 Eric Wong
  2016-06-13 23:01 ` [PATCH 2/1] doc: systemd examples should only kill one process Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2016-06-13 21:38 UTC (permalink / raw)
  To: meta

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   | 10 ++++++++++
 examples/public-inbox-httpd@.service | 29 +++++++++++++++++++++++++++++
 examples/public-inbox-nntpd.socket   | 10 ++++++++++
 examples/public-inbox-nntpd@.service | 31 +++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+)
 create mode 100644 examples/public-inbox-httpd.socket
 create mode 100644 examples/public-inbox-httpd@.service
 create mode 100644 examples/public-inbox-nntpd.socket
 create mode 100644 examples/public-inbox-nntpd@.service

diff --git a/examples/public-inbox-httpd.socket b/examples/public-inbox-httpd.socket
new file mode 100644
index 0000000..da37aec
--- /dev/null
+++ b/examples/public-inbox-httpd.socket
@@ -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
index 0000000..3bb7072
--- /dev/null
+++ b/examples/public-inbox-httpd@.service
@@ -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
index 0000000..eeddf34
--- /dev/null
+++ b/examples/public-inbox-nntpd.socket
@@ -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
index 0000000..078e920
--- /dev/null
+++ b/examples/public-inbox-nntpd@.service
@@ -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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/1] doc: systemd examples should only kill one process
  2016-06-13 21:38 [PATCH] examples: systemd socket and service definitions for daemons Eric Wong
@ 2016-06-13 23:01 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2016-06-13 23:01 UTC (permalink / raw)
  To: meta

For our daemons, killing only the master process is enough.
Killing the entire control group (as done by default in
systemd) may cause subprocesses such as git to shut down
unexpectedly.

Having systemd kill workers directly will also cause an
immediate shutdown since the master would've already signaled
the workers; and workers will die after two shutdown requests.
---
 examples/public-inbox-httpd@.service | 1 +
 examples/public-inbox-nntpd@.service | 1 +
 examples/unsubscribe-psgi@.service   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/examples/public-inbox-httpd@.service b/examples/public-inbox-httpd@.service
index 3bb7072..6222de5 100644
--- a/examples/public-inbox-httpd@.service
+++ b/examples/public-inbox-httpd@.service
@@ -24,6 +24,7 @@ User = nobody
 Group = nogroup
 ExecReload = /bin/kill -HUP $MAINPID
 TimeoutStopSec = 3600
+KillMode = process
 
 [Install]
 WantedBy = multi-user.target
diff --git a/examples/public-inbox-nntpd@.service b/examples/public-inbox-nntpd@.service
index 078e920..3e203e0 100644
--- a/examples/public-inbox-nntpd@.service
+++ b/examples/public-inbox-nntpd@.service
@@ -26,6 +26,7 @@ User = nobody
 Group = nogroup
 ExecReload = /bin/kill -HUP $MAINPID
 TimeoutStopSec = 3600
+KillMode = process
 
 [Install]
 WantedBy = multi-user.target
diff --git a/examples/unsubscribe-psgi@.service b/examples/unsubscribe-psgi@.service
index 2dc4270..acc29e8 100644
--- a/examples/unsubscribe-psgi@.service
+++ b/examples/unsubscribe-psgi@.service
@@ -15,6 +15,7 @@ ExecStart = /usr/local/bin/public-inbox-httpd -W0 /etc/unsubscribe.psgi
 Sockets = unsubscribe-psgi.socket
 # we need to modify the mlmmj spool
 User = mlmmj
+KillMode = process
 
 [Install]
 WantedBy = multi-user.target


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-13 23:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-13 21:38 [PATCH] examples: systemd socket and service definitions for daemons Eric Wong
2016-06-13 23:01 ` [PATCH 2/1] doc: systemd examples should only kill one process Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).