From: Tomas Krizek Date: Mon, 4 Jun 2018 15:05:46 +0000 (+0200) Subject: distro/systemd: use kresd.target to start enabled instances X-Git-Tag: v2.4.0~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21958b1c8404f80b392442f4ab78d600bf62cb6c;p=thirdparty%2Fknot-resolver.git distro/systemd: use kresd.target to start enabled instances Starting multiple systemd units with a target is conceptually cleaner than using globbing expression. Related https://github.com/systemd/systemd/issues/9080 --- diff --git a/NEWS b/NEWS index c17451671..0ac92a1dc 100644 --- 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) diff --git a/distro/arch/PKGBUILD b/distro/arch/PKGBUILD index 26644b20c..1df34a4d5 100644 --- a/distro/arch/PKGBUILD +++ b/distro/arch/PKGBUILD @@ -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" diff --git a/distro/common/systemd/README.md b/distro/common/systemd/README.md index 3d8a8db86..433f92fb0 100644 --- a/distro/common/systemd/README.md +++ b/distro/common/systemd/README.md @@ -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. diff --git a/distro/common/systemd/kresd.systemd.7 b/distro/common/systemd/kresd.systemd.7 index 4fbba04c7..7e6d974e1 100644 --- a/distro/common/systemd/kresd.systemd.7 +++ b/distro/common/systemd/kresd.systemd.7 @@ -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 index 000000000..9cf5cbc34 --- /dev/null +++ b/distro/common/systemd/kresd.target @@ -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 diff --git a/distro/common/systemd/kresd@.service b/distro/common/systemd/kresd@.service index 39ac4bbf8..bf19f197c 100644 --- a/distro/common/systemd/kresd@.service +++ b/distro/common/systemd/kresd@.service @@ -14,4 +14,4 @@ Sockets=kresd-tls.socket Sockets=kresd-control@%i.socket [Install] -WantedBy=multi-user.target +WantedBy=kresd.target diff --git a/distro/deb/debian/knot-resolver.install b/distro/deb/debian/knot-resolver.install index a78583aef..379ae695c 100644 --- a/distro/deb/debian/knot-resolver.install +++ b/distro/deb/debian/knot-resolver.install @@ -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 diff --git a/distro/deb/debian/knot-resolver.links b/distro/deb/debian/knot-resolver.links index 98313e175..8196524dd 100644 --- a/distro/deb/debian/knot-resolver.links +++ b/distro/deb/debian/knot-resolver.links @@ -1 +1,2 @@ dev/null lib/systemd/system/kresd.service +lib/systemd/system/kresd.target lib/systemd/system/multi-user.target.wants/kresd.target diff --git a/distro/rpm/knot-resolver.spec b/distro/rpm/knot-resolver.spec index 791dea875..5a86c498e 100644 --- a/distro/rpm/knot-resolver.spec +++ b/distro/rpm/knot-resolver.spec @@ -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