Re: [systemd-devel] Depending on services from a service unit template

2016-07-08 Thread Andrei Borzenkov
08.07.2016 22:01, Lennart Poettering пишет:
> On Fri, 01.07.16 06:37, Andrei Borzenkov (arvidj...@gmail.com) wrote:
> 
>> In principle, I do not see why we cannot have WantedBy and RequiredBy as
>> first class directives under [Unit] to spare all these hoops.
> 
> systemd loads unit files as they are requested, by following
> dependencies. i.e. when we see Wants=foobar.service in a file
> quux.service, and quux.service is loaded because it shall be started
> then we'll load foobar.service too. systemd does not load unit files
> that are not referenced by any other unit. It hence minimizes what it
> loads, and it does *not* iterate through the unit dirs loading
> everything it finds there.
> 
> Now, if we would permit WantedBy= in [Unit], this would mean that if a
> unit file waldo.service carries WantedBy=miau.service in [Unit], then
> when miau.service is requested to be started we would somehow have to
> determine that waldo.service is to be loaded and started too. But how
> could we do that without loading all possible unit files as boot? i
> mean, how would we efficiently detect that waldo.service needs to be
> loaded when just looking at miau.service if the latter does not carry
> in anyway information about the former?
> 

I see, yes, I did not consider it. Thank you for explanation.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Depending on services from a service unit template

2016-07-08 Thread Lennart Poettering
On Mon, 27.06.16 08:25, Paul Menzel (paulepan...@users.sourceforge.net) wrote:

> Dear systemd folks,
> 
> 
> having a template for a service unit like `example@.service`, and
> starting several services from it, is there a way, to let another
> service unit require all services started from that template?

Well, what does "all instances" even mean? Note that instances can be
instantiated dynamically. i.e. without having a unit file
foo@bar.service on disk you can simply by having foo@.service on disk
make "systemctl start foo@bar.service" work. Hence, if you want some
other service to have deps onto "all" instances of foo@.service, then
this would mean you'd have to add deps for really all theoretically
possible instance strings, and those are quite a few...

Now, what would make more sense if by "all" you just mean "all *enabled*
instances". if that's what you mean then RequiredBy= in [Install]
should do what you need.

Alternatively, if by "all" you mean "all *running" instances", then
you could use PartOf= in the instance unit file instead of
Requires=. The effective difference is that only stops are propagated,
but not starts.

Hope this makes some sense,

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Depending on services from a service unit template

2016-07-08 Thread Lennart Poettering
On Fri, 01.07.16 06:37, Andrei Borzenkov (arvidj...@gmail.com) wrote:

> In principle, I do not see why we cannot have WantedBy and RequiredBy as
> first class directives under [Unit] to spare all these hoops.

systemd loads unit files as they are requested, by following
dependencies. i.e. when we see Wants=foobar.service in a file
quux.service, and quux.service is loaded because it shall be started
then we'll load foobar.service too. systemd does not load unit files
that are not referenced by any other unit. It hence minimizes what it
loads, and it does *not* iterate through the unit dirs loading
everything it finds there.

Now, if we would permit WantedBy= in [Unit], this would mean that if a
unit file waldo.service carries WantedBy=miau.service in [Unit], then
when miau.service is requested to be started we would somehow have to
determine that waldo.service is to be loaded and started too. But how
could we do that without loading all possible unit files as boot? i
mean, how would we efficiently detect that waldo.service needs to be
loaded when just looking at miau.service if the latter does not carry
in anyway information about the former?

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Depending on services from a service unit template

2016-06-30 Thread Andrei Borzenkov
01.07.2016 00:50, Paul Menzel пишет:
> Dear Michael, dear Andrei,
> 
> 
> Thank you for replying.
> 
> 
> Am Montag, den 27.06.2016, 15:37 +0200 schrieb Michael Biebl:
>> 2016-06-27 13:49 GMT+02:00 Andrei Borzenkov :
>>> On Mon, Jun 27, 2016 at 9:25 AM, Paul Menzel wrote:
> 
 having a template for a service unit like `example@.service`, and
 starting several services from it, is there a way, to let another
 service unit require all services started from that template?
>>>
>>> I do not think it is possible. In other direction it may work with
>>> some workaround (i.e. make every instance of template be required
>>> by specific services).
>>
>> PartOf= in the template service might be what you are looking for.
> 
> From the manual page systemd.unit:
> 
>>PartOf=
>>Configures dependencies similar to Requires=, but limited
>> to stopping and restarting of units. When systemd stops or restarts
>> the units listed here, the action is propagated to this unit. Note
>> that this is a one-way dependency — changes to this unit do not
>> affect the listed units.
> 
> So, it could indeed be what I am looking for. In my use case, it
> doesn’t feel right yet though.
> 
> There are several instances of a Web application started from
> example@.service. In front of it is the proxy HAProxy.
> 
> So in my reading, saying that the Web application instances is a *part
> of* HAProxy, doesn’t totally feel/sound right to me.
> 
> Also, asking for `Requires=` was, that HAProxy seems to check the
> configured backends to run, and refuses to start if they don’t. That’s
> why, all the Web applications are required before the HAProxy start-up.
> 
> If I am not mistaken, `PartOf=` does not solve that problem.
> 
> Do you have another suggestion?
> 

This is exact use case I meant. Put

[Install]
RequiredBy=HAProxy.service

in example@.service template; then "systemctl enable
example@instance.service" will automatically add link to
.../HAProxy.service.requires directory.

Downside is that you need to statically configure all instances but as I
understand HAProxy must know them in advance anyway.

In principle, I do not see why we cannot have WantedBy and RequiredBy as
first class directives under [Unit] to spare all these hoops.



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Depending on services from a service unit template

2016-06-30 Thread Paul Menzel
Dear Michael, dear Andrei,


Thank you for replying.


Am Montag, den 27.06.2016, 15:37 +0200 schrieb Michael Biebl:
> 2016-06-27 13:49 GMT+02:00 Andrei Borzenkov :
> > On Mon, Jun 27, 2016 at 9:25 AM, Paul Menzel wrote:

> > > having a template for a service unit like `example@.service`, and
> > > starting several services from it, is there a way, to let another
> > > service unit require all services started from that template?
> > 
> > I do not think it is possible. In other direction it may work with
> > some workaround (i.e. make every instance of template be required
> > by specific services).
> 
> PartOf= in the template service might be what you are looking for.

From the manual page systemd.unit:

>    PartOf=
>    Configures dependencies similar to Requires=, but limited
> to stopping and restarting of units. When systemd stops or restarts
> the units listed here, the action is propagated to this unit. Note
> that this is a one-way dependency — changes to this unit do not
> affect the listed units.

So, it could indeed be what I am looking for. In my use case, it
doesn’t feel right yet though.

There are several instances of a Web application started from
example@.service. In front of it is the proxy HAProxy.

So in my reading, saying that the Web application instances is a *part
of* HAProxy, doesn’t totally feel/sound right to me.

Also, asking for `Requires=` was, that HAProxy seems to check the
configured backends to run, and refuses to start if they don’t. That’s
why, all the Web applications are required before the HAProxy start-up.

If I am not mistaken, `PartOf=` does not solve that problem.

Do you have another suggestion?


Thanks,

Paul

signature.asc
Description: This is a digitally signed message part
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Depending on services from a service unit template

2016-06-27 Thread Michael Biebl
2016-06-27 13:49 GMT+02:00 Andrei Borzenkov :
> On Mon, Jun 27, 2016 at 9:25 AM, Paul Menzel
>  wrote:
>> Dear systemd folks,
>>
>>
>> having a template for a service unit like `example@.service`, and
>> starting several services from it, is there a way, to let another
>> service unit require all services started from that template?
>>
>
> I do not think it is possible. In other direction it may work with
> some workaround (i.e. make every instance of template be required by
> specific services).


PartOf= in the template service might be what you are looking for.


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Depending on services from a service unit template

2016-06-27 Thread Andrei Borzenkov
On Mon, Jun 27, 2016 at 9:25 AM, Paul Menzel
 wrote:
> Dear systemd folks,
>
>
> having a template for a service unit like `example@.service`, and
> starting several services from it, is there a way, to let another
> service unit require all services started from that template?
>

I do not think it is possible. In other direction it may work with
some workaround (i.e. make every instance of template be required by
specific services).
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Depending on services from a service unit template

2016-06-26 Thread Paul Menzel
Dear systemd folks,


having a template for a service unit like `example@.service`, and
starting several services from it, is there a way, to let another
service unit require all services started from that template?


Thanks,

Paul

signature.asc
Description: This is a digitally signed message part
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel