]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
distro/systemd: use kresd.target to start enabled instances
authorTomas Krizek <tomas.krizek@nic.cz>
Mon, 4 Jun 2018 15:05:46 +0000 (17:05 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Mon, 2 Jul 2018 15:46:50 +0000 (17:46 +0200)
Starting multiple systemd units with a target is conceptually cleaner
than using globbing expression.

Related https://github.com/systemd/systemd/issues/9080

NEWS
distro/arch/PKGBUILD
distro/common/systemd/README.md
distro/common/systemd/kresd.systemd.7
distro/common/systemd/kresd.target [new file with mode: 0644]
distro/common/systemd/kresd@.service
distro/deb/debian/knot-resolver.install
distro/deb/debian/knot-resolver.links
distro/rpm/knot-resolver.spec

diff --git a/NEWS b/NEWS
index c174516712306610d0b8027493856bee4046c54f..0ac92a1dc7e91bf67af797d7df98f2abe1ec90ca 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ Bugfixes
 
 Improvements
 ------------
+- systemd: multiple enabled kresd instances can now be started using kresd.target
 - ta_sentinel: switch to version 14 of the RFC draft (!596)
 - support for glibc systems with a non-Linux kernel (!588)
 - support per-request variables for Lua modules (!533)
index 26644b20c65bf6d213b79c134795422a5f700d02..1df34a4d5e6e077eee0925b020971c5300bc2fd7 100644 (file)
@@ -49,6 +49,9 @@ package() {
        install -Dm 0644 "${srcdir}/${pkgname}-${pkgver}/distro/common/systemd/kresd-control@.socket" "${pkgdir}/usr/lib/systemd/system/kresd-control@.socket"
        install -Dm 0644 "${srcdir}/${pkgname}-${pkgver}/distro/common/systemd/kresd-tls.socket" "${pkgdir}/usr/lib/systemd/system/kresd-tls.socket"
        install -Dm 0644 "${srcdir}/${pkgname}-${pkgver}/distro/common/systemd/kresd@.service" "${pkgdir}/usr/lib/systemd/system/kresd@.service"
+       install -Dm 0644 "${srcdir}/${pkgname}-${pkgver}/distro/common/systemd/kresd.target" "${pkgdir}/usr/lib/systemd/system/kresd.target"
+       install -dm 0755 "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants"
+       ln -s ../kresd.target "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants/kresd.target"
        install -Dm 0644 "${srcdir}/${pkgname}-${pkgver}/distro/common/systemd/kresd.systemd.7" "${pkgdir}/usr/share/man/man7/kresd.systemd.7"
        install -Dm 0644 "${srcdir}/${pkgname}-${pkgver}/distro/common/tmpfiles/knot-resolver.conf" "${pkgdir}/usr/lib/tmpfiles.d/knot-resolver.conf"
        install -dm 0775 "${pkgdir}/etc/knot-resolver"
index 3d8a8db86209200a7467c08e141ec37b178a62a3..433f92fb06ad6ecf12841f0e57c233c99d515aa9 100644 (file)
@@ -26,3 +26,6 @@ Notes
 *  Distributions using systemd-sysv-generator should mask kresd.service to
    be consistent with other distributions. Any use of kresd.service instead of
    kresd@N.service is discouraged to avoid confusing the users.
+*  kresd.target should be enabled by default by linking it to systemd lib/
+   directory. Instances of kresd@.service are then added manually to
+   kresd.target when the user enables them.
index 4fbba04c753951b744d106f86e249d88e2c59ea4..7e6d974e1e8f2eee7641b83abe1628551659543e 100644 (file)
@@ -1,4 +1,4 @@
-.TH "kresd.systemd" "7" "2018-01-30" "CZ.NIC" "Knot DNS Resolver Systemd Units"
+.TH "kresd.systemd" "7" "2018-06-04" "CZ.NIC" "Knot DNS Resolver Systemd Units"
 .\"
 .\" kresd.systemd.7 -- man page for systemd units for kresd
 .\"
@@ -17,6 +17,7 @@ kresd@.service
 kresd.socket
 kresd-tls.socket
 kresd-control@.socket
+kresd.target
 system-kresd.slice
 .fi
 
@@ -99,7 +100,7 @@ number.  To enable 3 concurrent daemons:
 .RE
 .fi
 
-.B Using system-kresd.slice
+.B Using system-kresd.slice and kresd.target
 
 The following commands may not work with older systemd (e.g. on CentOS 7).
 See notes for more info.
@@ -129,13 +130,11 @@ Or you can use it to stop kresd altogether (e.g. during package removal):
 .RE
 .fi
 
-Note that \fBsystemctl start system-kresd.slice\fR does not
-automatically start the sockets or the daemons, though.  To ensure
-that all enabled daemons are started and running, do:
+To start all enabled kresd daemons, use the provided \fIkresd.target\fR:
 
 .nf
 .RS 4n
-.B systemctl start --all 'kresd@*.service'
+.B systemctl start kresd.target
 .RE
 .fi
 
@@ -212,7 +211,7 @@ To enable multiple concurrent daemons, for example 16:
 To start all enabled daemons:
 .nf
 .RS
-.B systemctl start --all 'kresd@*.service'
+.B systemctl start kresd.target
 .RE
 .fi
 
diff --git a/distro/common/systemd/kresd.target b/distro/common/systemd/kresd.target
new file mode 100644 (file)
index 0000000..9cf5cbc
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Knot DNS Resolver daemons
+Documentation=man:kresd.systemd(7)
+Documentation=man:kresd(8)
+After=syslog.target network-online.target
+
+[Install]
+WantedBy=multi-user.target
index 39ac4bbf85aa314ffa9c5a68ae3beb27ffc413b7..bf19f197c95a46f7ea330a9ad31c2c1081cf30f4 100644 (file)
@@ -14,4 +14,4 @@ Sockets=kresd-tls.socket
 Sockets=kresd-control@%i.socket
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=kresd.target
index a78583aef7d774ca28c4dd6f51e04252decd1b8c..379ae695c997bb7410d230d1c301e6d581eee423 100644 (file)
@@ -5,6 +5,7 @@ distro/common/systemd/kresd-control@.socket lib/systemd/system/
 distro/common/systemd/kresd-tls.socket lib/systemd/system/
 distro/common/systemd/kresd.socket lib/systemd/system/
 distro/common/systemd/kresd@.service lib/systemd/system/
+distro/common/systemd/kresd.target lib/systemd/system/
 distro/common/tmpfiles/knot-resolver.conf usr/lib/tmpfiles.d/
 usr/lib/knot-resolver/*.so
 usr/lib/knot-resolver/daf.lua
index 98313e175b34c439ba3ea5f38ee0d75895a03fe5..8196524dd760cf2eeb6e4ccb42aebbb79f4f0cc0 100644 (file)
@@ -1 +1,2 @@
 dev/null lib/systemd/system/kresd.service
+lib/systemd/system/kresd.target lib/systemd/system/multi-user.target.wants/kresd.target
index 791dea8752a5a372f6425fd070dc7bfa42c01620..5a86c498e365d84012e889df0c5785e2b5186ce3 100644 (file)
@@ -139,6 +139,9 @@ install -m 0664 -p %SOURCE3 %{buildroot}%{_sysconfdir}/knot-resolver/root.keys
 # install systemd units and doc
 mkdir -p %{buildroot}%{_unitdir}
 install -m 0644 -p %{repodir}/distro/common/systemd/kresd@.service %{buildroot}%{_unitdir}/kresd@.service
+install -m 0644 -p %{repodir}/distro/common/systemd/kresd.target %{buildroot}%{_unitdir}/kresd.target
+install -m 0755 -d %{buildroot}%{_unitdir}/multi-user.target.wants
+ln -s ../kresd.target %{buildroot}%{_unitdir}/multi-user.target.wants/kresd.target
 mkdir -p %{buildroot}%{_mandir}/man7
 install -m 0644 -p %{repodir}/distro/common/systemd/kresd.systemd.7 %{buildroot}%{_mandir}/man7/kresd.systemd.7
 
@@ -213,6 +216,8 @@ fi
 %attr(644,root,knot-resolver) %config(noreplace) %{_sysconfdir}/knot-resolver/icann-ca.pem
 %attr(750,knot-resolver,knot-resolver) %dir %{_localstatedir}/cache/knot-resolver
 %{_unitdir}/kresd*.service
+%{_unitdir}/kresd.target
+%{_unitdir}/multi-user.target.wants/kresd.target
 %if 0%{?rhel}
 %{_unitdir}/kresd@.service.d/override.conf
 %endif