[systemd-devel] WantedBy=default.target
Lennart Poettering
lennart at poettering.net
Thu Mar 7 10:24:08 UTC 2019
On Do, 07.03.19 10:30, Michael Biebl (mbiebl at gmail.com) wrote:
> Looks like quite a few services use
> WantedBy=default.target
> https://codesearch.debian.net/search?q=WantedBy%3Ddefault.target
>
> Some of them are user services, but I wonder if there is
> recommendation regarding system services.
> Should they use multi-user.target or graphical.target instead or is it
> ok for system services to hook into default.target?
Usually doing this for system services is wrong, but there are
exceptions.
A few points:
1. If you hook into default.target then you are started regardless
what is configured to be the default target to boot into.
2. When the user picks a different boot target using the kernel
cmdline (e.g. by specifying 'systemd.unit=…', or 'emergency' or '1' or '5'
or so on it) it has no effect though, as that means default.target
is not considered.
3. graphical.target pulls in multi-user.target anyway, hence hooking
into the latter should generally cover all grounds of "normal boot"
anyway, as it is pulled into all regular boot targets.
Or in other words: if people want to declare "run me on every boot",
then #1 above means you get too much, #2 means you get too little, and
#3 means you don't need it anyway as other stuff is better...
Browsing through the link you posted, it appears at least the
following packages are doing it wrong:
1. havegd
2. rtags (it uses default.target in a socket file, which is even
weirder, should use sockets.target)
2. openrazer
And there are probably more, but sometimes it's hard to figure out if
they are user or system services...
It might make sense to extend "systemd-analyze" in some form to warn
about this, maybe file an RFE bug about that?
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list