correct systemd-rpm-macros usage in pkg .spec pre*/post* with .timer-controlled service groups?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i'm moving a group of systemd-controlled server services off of the critical boot path, on Fedora 39.

i build/package the services myself, from .spec (mock or COPR), and need to adapt the specs' systemd-rpm-macros usage.

to get them off the critial path, i've grouped the service in a unit.target, controlled by a unit.timer,

	cat /etc/systemd/system/daemon{A,B,C}.service
		...
		[Install]
	-	WantedBy=graphical.target
	+	Also=daemon-group.timer


	cat /etc/systemd/system/daemon-group.target
		[Unit]
		Description=daemon-group target
		Wants=daemonA.service daemonB.service daemonC.service
		After=daemonA.service daemonB.service daemonC.service

		[Install]
		Also=daemon-group.timer

	cat /etc/systemd/system/daemon-group.timer
		[Unit]
		Description=startup daemon-group
		After=syslog.target network-online.target

		[Timer]
		OnActiveSec=1s
		Unit=daemon-group.target

		[Install]
		WantedBy=timers.target

then

	systemctl enable --now daemon-group.timer

as intended, the timer unit now controls group start/stop, with ordering deps handled within each daemon{A,B,C}.service unit,

	systemctl status daemonA daemonB daemonC | grep indirect
		Loaded: loaded (/etc/systemd/system/daemonA.service; indirect; preset: disabled)
		Loaded: loaded (/etc/systemd/system/daemonB.service; indirect; preset: disabled)
		Loaded: loaded (/etc/systemd/system/daemonC.service; indirect; preset: disabled)

, not via typical direct systemctl of the individual units.

where, e.g.,

	cat /usr/lib/rpm/macros.d/macros.systemd
		...
		%systemd_postun_with_restart() \
		%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun_with_restart}} \
		if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then \
		    # Package upgrade, not uninstall \
		    /usr/lib/systemd/systemd-update-helper mark-restart-system-units %{?*} || : \
		fi \
		%{nil}
		...

	cat /usr/lib/systemd/systemd-update-helper
		...
		mark-restart-system-units)
		        [ -d /run/systemd/system ] || exit 0

		        for unit in "$@"; do
		            systemctl set-property "$unit" Markers=+needs-restart &
		        done
		        wait
		        ;;
		...

with this setup, @ shell,

	systemctl stop daemon<X>.service

correctly stops a single service.

but

	systemctl (re)start daemon<X>.service

fails to release back to prompt

otoh,

	systemctl stop daemon<X>.service
	systemctl restart daemon-group.timer

does. but, appears to restart all services ref'd in the timer group.

on pkg upgrade, i need to properly handle the service/timer controls in the spec.

the original daemon{A,B,C}.spec has systemd-rpm-macros in place for pre-/post install handling,
	...
	BuildRequires:     systemd
	BuildRequires:     systemd-rpm-macros
	%{?systemd_requires}
	...
	%post
	%systemd_post daemon<X>.service

	%preun
	%systemd_preun daemon<X>.service

	%postun
	%systemd_postun_with_restart daemon<X>.service
	...


what's correct systemd unit control usage in this case?

keep post/pre macro invocations referencing the daemon<X>.service ?
switch to mixed/sole macro control of daemon-group.timer?
or, can't use the macros in this case, and have to use explicit manual control?

--
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux