document systemd service setup
authorChristian Weiske <cweiske@cweiske.de>
Thu, 20 Apr 2017 21:47:19 +0000 (23:47 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 20 Apr 2017 21:47:19 +0000 (23:47 +0200)
README.rst
data/systemd/phinde.service [new file with mode: 0644]
data/systemd/phinde@.service [new file with mode: 0644]

index 1008361..0008b60 100644 (file)
@@ -46,7 +46,28 @@ Dependencies
 =====
 Setup
 =====
-This section is incomplete.
+FIXME: This section is incomplete.
+
+
+System service
+==============
+When using systemd, you can let it run multiple worker instances when
+the system boots up:
+
+#. Copy files ``data/systemd/phinde*.service`` into ``/etc/systemd/system/``
+#. Adjust user and group names, and the work directories
+#. Enable three worker processes::
+
+     $ systemctl daemon-reload
+     $ systemctl enable phinde@1
+     $ systemctl enable phinde@2
+     $ systemctl enable phinde@3
+     $ systemctl enable phinde
+     $ systemctl start phinde
+#. Now three workers are running. Restarting the ``phinde`` service also
+   restarts the workers.
+
+
 
 Cron job
 ========
diff --git a/data/systemd/phinde.service b/data/systemd/phinde.service
new file mode 100644 (file)
index 0000000..18ee640
--- /dev/null
@@ -0,0 +1,18 @@
+# This is a mostly empty service, but allows commands like stop, start, reload
+# to propagate to all phinde@ service instances.
+
+[Unit]
+Description=phinde search server
+After=network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/true
+ExecReload=/bin/true
+WorkingDirectory=/home/cweiske/www/search.cweiske.de/
+User=cweiske
+Group=www-cweiske
+
+[Install]
+WantedBy=multi-user.target
diff --git a/data/systemd/phinde@.service b/data/systemd/phinde@.service
new file mode 100644 (file)
index 0000000..2b3c611
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=phinde worker %i
+PartOf=phinde.service
+ReloadPropagatedFrom=phinde.service
+
+[Service]
+Type=simple
+WorkingDirectory=/home/cweiske/www/search.cweiske.de/
+User=cweiske
+Group=www-cweiske
+ExecStart=/home/cweiske/www/search.cweiske.de/bin/phinde-worker.php
+TimeoutStopSec=5
+Restart=always
+RestartSec=60
+
+[Install]
+WantedBy=phinde.service