Re: [systemd-devel] Q: Wanting a target

2022-02-23 Thread Mantas Mikulėnas
On Wed, Feb 23, 2022 at 3:40 PM Ulrich Windl <
ulrich.wi...@rz.uni-regensburg.de> wrote:

> Hi!
>
> I think there was a recent discussion saying that no unit should Want= or
> Require= a target, but only use them for ordering.
> I have basically three questions:
>
> 1) Is the statement above correct?
>

Not for all targets in general. It may be correct for some .targets but not
others, and for some services but not others, but something *does* need to
pull the target in as a dependency, otherwise it would never be started –
there's (almost) nothing special in ordering against targets,
After=foo.target only waits for foo.target to become "started" like for
other unit types.

Some of the systemd-provided targets differ in whether the "provider" vs
"consumer" should Want them. For example, systemd.special(7) says that
Wants=network.target should go in the network provider (so other services
only need an After), while Wants=network-online.target would go in the
"consumer" service that wants to *wait* for network (as the target itself
has dependencies that shouldn't be started unless needed).

For some targets, "Wants or no Wants" follows the same rules as for
services – e.g. tinc VPN became multi-instance and got a .target to cover
all instances, so if you previously wouldn't have used Wants=tinc.service
but only After, then the same applies to the new .target as well.


>
> 2) When is a target displayed as "started" by sysctemctl status then?
>

When it gets started.


>
> 3: Which of the following (form current SLES12 SP5, grep-style) are wrong?:
>
> /usr/lib/systemd/system/ntpd.service:Wants=network.target
> /usr/lib/systemd/system/ntpd.service:After=network.target
>
> /usr/lib/systemd/system/nfs-server.service:Requires= network.target
> proc-fs-nfsd.mount
> /usr/lib/systemd/system/nfs-server.service:After= network.target
> proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service
>
> /usr/lib/systemd/system/nmb.service:After=network.target
>

According to docs for network.target, it's the first two that are "wrong".

-- 
Mantas Mikulėnas


[systemd-devel] Q: Wanting a target

2022-02-23 Thread Ulrich Windl
Hi!

I think there was a recent discussion saying that no unit should Want= or 
Require= a target, but only use them for ordering.
I have basically three questions:

1) Is the statement above correct?

2) When is a target displayed as "started" by sysctemctl status then?

3: Which of the following (form current SLES12 SP5, grep-style) are wrong?:

/usr/lib/systemd/system/ntpd.service:Wants=network.target
/usr/lib/systemd/system/ntpd.service:After=network.target

/usr/lib/systemd/system/nfs-server.service:Requires= network.target 
proc-fs-nfsd.mount
/usr/lib/systemd/system/nfs-server.service:After= network.target 
proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service

/usr/lib/systemd/system/nmb.service:After=network.target

Regards,
Ulrich