[systemd-devel] Still confused with socket activation

Andrei Borzenkov arvidjaar at gmail.com
Thu Feb 4 19:16:26 UTC 2021


03.02.2021 22:25, Benjamin Berg пишет:
> On Wed, 2021-02-03 at 20:47 +0300, Andrei Borzenkov wrote:
>> 03.02.2021 00:25, Benjamin Berg пишет:
>>> On Tue, 2021-02-02 at 22:50 +0300, Andrei Borzenkov wrote:
>>>> 02.02.2021 17:59, Lennart Poettering пишет:
>>>>>
>>>>> Note that Requires= in almost all cases should be combined with
>>>>> an
>>>>> order dep of After= onto the same unit.
>>>>
>>>> Years ago I asked for example when Requires makes sense without
>>>> After.
>>>> Care to show it? I assume you must have use case if you say "in
>>>> almost all".
>>>
>>> In the GNOME systemd units there are a few places where a Requires=
>>> is
>>> combined with Before=.
>>>
>>
>> This is functionally completely equivalent to simply using
>> Wants+Before.
>> At least as long as you rely on *documented* functions.
> 
> Requires= actually has the difference that the unit must become part of
> the transaction (if it is not active already). So you get a hard
> failure and appropriate logging if the unit cannot be added to the
> transaction for some reason.
> 

Oh, I said "documented" :) systemd documentation does not even define
what "transaction" is. You really need to know low level implementation
details to use it in this way.

But thank you, I missed this subtlety. Of course another reason could be
stop behavior.

>> Care to show more complete example and explain why Wants does not
>> work in this case?
> 
> Wants= would work fine. I think it boils down to whether you find the
> extra assertions useful. The Requires= documentation actually suggests
> using Wants= exactly to avoid this.
> 
> Benjamin
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210204/6a01d305/attachment.sig>


More information about the systemd-devel mailing list