[systemd-devel] Antw: Re: Q: Wants and WantedBy links in generated units and circular dependencies

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Thu May 23 11:03:30 UTC 2019


>>> Andrei Borzenkov <arvidjaar at gmail.com> schrieb am 23.05.2019 um 12:41 in
Nachricht
<CAA91j0WdcF=KTWrxrQkiYisSiR1J16VzD0aVn1fFg0vEh1TkTA at mail.gmail.com>:
> On Thu, May 23, 2019 at 11:56 AM Ulrich Windl
> <Ulrich.Windl at rz.uni-regensburg.de> wrote:
>>
>> Hi!
>>
>> After seeing that systemd generators are run as the very first step in
>> systemd's life (deduced from the timestamps), I quit the idea of using
them,
>> and started to use another sort of generator:
>>
>> I have a generator target, that creates another target and a few service
>> targets.
>> The interesting point is circular dependencies for the generated units,
and
>> I'd like to ask if the following would work:
>>
>> I need to enable a generated target to get ist wants-links installed; 
> likewise
>> the generated service units need to be enabled to get the wants link from 
> the
>> target to the service.
>> As my generator created the service units first, then the target unit
which
>> "Wants" the service units.
>> The idea is that starting the soingle target unit will start all depending
>> service units.
>>
>> So far that is without enabling. I wonder whether I can enable the service
>> units that are "WantedBy" the target unit _before_ the target unit was 
> actually
>> generated.
> 
> If target unit Wants your service units, there is nothing to enable.

I want to avoid the confusing "Reason: No such file or directory".

> 
>> If that doesn't work, I'll need a two-pass approach.
>>
>> For history, one of the odd things in systemd v228 is this:
>>  # systemctl status iotwatch.target
>> ● iotwatch.target
>>    Loaded: not-found (Reason: No such file or directory)
>>    Active: inactive (dead)
>> # systemctl enable iotwatch.target   ### thios command must do something
>> magic!
> 
> It also implicitly does "systemctl daemon-reload". It should not
> really be necessary in this case (systemd should attempt to load
> missing definition) but with so old version who knows.

The advantage of "enable" is that it outputs messages that show what it is
doing;.

> 
>> # systemctl status iotwatch.target
>> ● iotwatch.target - iotwatch I/O performance monitor
>>    Loaded: loaded (/run/systemd/system/iotwatch.target; enabled; vendor
>> preset: disabled)
>>    Active: inactive (dead)
>>      Docs: man:iotwatch at .service(8)
>>            man:iotwatch-generator(8)
>>
>>
>> So it seems I must enable units just to be able to query whether they are
>> enabled...???
>>
> 
> systemctl is-enabled

Will "is-enabled" work where "status" fails with "Reason: No such file or
directory"?

Regards,
Ulrich



More information about the systemd-devel mailing list