Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-03-08 Thread 林自均
Hi Zbyszek,

Thank you for your explanation.

However, I found that Conflicts= will be a good choice for me:

# /etc/systemd/system/my-apps-start.target
[Unit]
Wants=docker.service sshd.service mongodb.service

# /etc/systemd/system/my-apps-stop.target
[Unit]
Conflicts=docker.service sshd.service mongodb.service
After=docker.service sshd.service mongodb.service

Then

systemctl start my-apps-start.target # starts all my apps
systemctl start my-apps-stop.target # stops all my apps

And both operations are sync, i.e. will wait for all apps to be
started/stopped before systemctl exits.

Thank you all for solving my problems.

John Lin

Zbigniew Jędrzejewski-Szmek  於 2018年3月7日 週三 下午8:48寫道:

> On Tue, Mar 06, 2018 at 03:07:30AM +, 林自均 wrote:
> > Anyone?
> >
> > John Lin
> >
> > 林自均  於 2018年2月27日 週二 下午6:20寫道:
> >
> > > Hi Jérémy,
> > >
> > > Thank you, but I read the section "Mapping of unit properties to their
> > > inverses" in the man page
> > > https://www.freedesktop.org/software/systemd/man/systemd.unit.html and
> > > then found out the PropagatesReloadTo= and ReloadPropagatedFrom= are
> > > inverses to each other and both can be configured in a unit file. I was
> > > wondering why PartOf= and ConsistsOf= are not the case. Thank you.
>
> No particular reason, just noobody got around to implementing the
> parsing of that option. Shouldn't be too hard though.
>
> Zbyszek
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-03-07 Thread Zbigniew Jędrzejewski-Szmek
On Tue, Mar 06, 2018 at 03:07:30AM +, 林自均 wrote:
> Anyone?
> 
> John Lin
> 
> 林自均  於 2018年2月27日 週二 下午6:20寫道:
> 
> > Hi Jérémy,
> >
> > Thank you, but I read the section "Mapping of unit properties to their
> > inverses" in the man page
> > https://www.freedesktop.org/software/systemd/man/systemd.unit.html and
> > then found out the PropagatesReloadTo= and ReloadPropagatedFrom= are
> > inverses to each other and both can be configured in a unit file. I was
> > wondering why PartOf= and ConsistsOf= are not the case. Thank you.

No particular reason, just noobody got around to implementing the
parsing of that option. Shouldn't be too hard though.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-03-05 Thread 林自均
Anyone?

John Lin

林自均  於 2018年2月27日 週二 下午6:20寫道:

> Hi Jérémy,
>
> Thank you, but I read the section "Mapping of unit properties to their
> inverses" in the man page
> https://www.freedesktop.org/software/systemd/man/systemd.unit.html and
> then found out the PropagatesReloadTo= and ReloadPropagatedFrom= are
> inverses to each other and both can be configured in a unit file. I was
> wondering why PartOf= and ConsistsOf= are not the case. Thank you.
>
> John Lin
>
>
> Jérémy Rosen  於 2018年2月27日 週二 下午4:35寫道:
>
>>
>>
>> On 27/02/2018 02:49, 林自均 wrote:
>>
>> Hi both Michal,
>>
>> Thank you for the quick responses! I think I will keep on using the tedious
>> PartOf= directive.
>>
>> However, may I ask why ConsistsOf= is readonly? If I can use it in my
>> "my-apps.target", that would be great.
>>
>> Because "ConsistsOf" doesn't exist in the way you think it does...
>>
>> Every relation between units (Wants, Before, PartOf) needs to have an
>> internal, reverse relation for accounting purpose
>>
>> That reverse relation is usually an internal detail, but it is handy to
>> expose
>> it in "systemctl show" & co.
>>
>> So that's what you see, an internal property exposed for ease-of-use. not
>> an
>> external, user configurable property
>>
>>
>>
>> John Lin
>>
>> Michal Koutný   於 2018年2月26日 週一 下午7:28寫道:
>>
>>
>>
>>
>> On 02/26/2018 11:08 AM, Michal Sekletar wrote:
>>
>> Unfortunately, we don't have a dependency (AFAIK) that only propagates
>> stop actions.
>>
>> FTR (not helpful for the original problem), there exists ConsistsOf= as
>> an inverse of PartOf= dependency. However, it's read only currently (or
>> strictly speaking, writable through the PartOf= endpoint).
>>
>> Michal
>>
>> ___
>> systemd-devel mailing 
>> listsystemd-devel@lists.freedesktop.orghttps://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
>>
>>
>> ___
>> systemd-devel mailing 
>> listsystemd-devel@lists.freedesktop.orghttps://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
>>
>> --
>> [image: SMILE] 
>>
>> 20 rue des Jardins
>> 92600 Asnières-sur-Seine
>> *Jérémy ROSEN*
>> Architecte technique
>> Responsable de l'expertise Smile-ECS
>>
>> [image: email] jeremy.ro...@smile.fr
>> [image: phone] +33141402967 <+33%201%2041%2040%2029%2067>
>> [image: url] http://www.smile.eu
>>
>> [image: Twitter]  [image: Facebook]
>>  [image: LinkedIn]
>>  [image: Github]
>> 
>>
>> [image: Découvrez l’univers Smile, rendez-vous sur smile.eu]
>> 
>>
>> [image: eco] Pour la planète, n'imprimez ce mail que si c'est nécessaire
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-02-27 Thread 林自均
Hi Jérémy,

Thank you, but I read the section "Mapping of unit properties to their
inverses" in the man page
https://www.freedesktop.org/software/systemd/man/systemd.unit.html and then
found out the PropagatesReloadTo= and ReloadPropagatedFrom= are inverses to
each other and both can be configured in a unit file. I was wondering why
PartOf= and ConsistsOf= are not the case. Thank you.

John Lin


Jérémy Rosen  於 2018年2月27日 週二 下午4:35寫道:

>
>
> On 27/02/2018 02:49, 林自均 wrote:
>
> Hi both Michal,
>
> Thank you for the quick responses! I think I will keep on using the tedious
> PartOf= directive.
>
> However, may I ask why ConsistsOf= is readonly? If I can use it in my
> "my-apps.target", that would be great.
>
> Because "ConsistsOf" doesn't exist in the way you think it does...
>
> Every relation between units (Wants, Before, PartOf) needs to have an
> internal, reverse relation for accounting purpose
>
> That reverse relation is usually an internal detail, but it is handy to
> expose
> it in "systemctl show" & co.
>
> So that's what you see, an internal property exposed for ease-of-use. not
> an
> external, user configurable property
>
>
>
> John Lin
>
> Michal Koutný   於 2018年2月26日 週一 下午7:28寫道:
>
>
>
>
> On 02/26/2018 11:08 AM, Michal Sekletar wrote:
>
> Unfortunately, we don't have a dependency (AFAIK) that only propagates
> stop actions.
>
> FTR (not helpful for the original problem), there exists ConsistsOf= as
> an inverse of PartOf= dependency. However, it's read only currently (or
> strictly speaking, writable through the PartOf= endpoint).
>
> Michal
>
> ___
> systemd-devel mailing 
> listsystemd-devel@lists.freedesktop.orghttps://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>
>
> ___
> systemd-devel mailing 
> listsystemd-devel@lists.freedesktop.orghttps://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>
> --
> [image: SMILE] 
>
> 20 rue des Jardins
> 92600 Asnières-sur-Seine
> *Jérémy ROSEN*
> Architecte technique
> Responsable de l'expertise Smile-ECS
>
> [image: email] jeremy.ro...@smile.fr
> [image: phone] +33141402967 <+33%201%2041%2040%2029%2067>
> [image: url] http://www.smile.eu
>
> [image: Twitter]  [image: Facebook]
>  [image: LinkedIn]
>  [image: Github]
> 
>
> [image: Découvrez l’univers Smile, rendez-vous sur smile.eu]
> 
>
> [image: eco] Pour la planète, n'imprimez ce mail que si c'est nécessaire
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-02-27 Thread Jérémy Rosen



On 27/02/2018 02:49, 林自均 wrote:

Hi both Michal,

Thank you for the quick responses! I think I will keep on using the tedious
PartOf= directive.

However, may I ask why ConsistsOf= is readonly? If I can use it in my
"my-apps.target", that would be great.

Because "ConsistsOf" doesn't exist in the way you think it does...

Every relation between units (Wants, Before, PartOf) needs to have an
internal, reverse relation for accounting purpose

That reverse relation is usually an internal detail, but it is handy to 
expose

it in "systemctl show" & co.

So that's what you see, an internal property exposed for ease-of-use. not an
external, user configurable property


John Lin

Michal Koutný  於 2018年2月26日 週一 下午7:28寫道:



On 02/26/2018 11:08 AM, Michal Sekletar wrote:

Unfortunately, we don't have a dependency (AFAIK) that only propagates
stop actions.

FTR (not helpful for the original problem), there exists ConsistsOf= as
an inverse of PartOf= dependency. However, it's read only currently (or
strictly speaking, writable through the PartOf= endpoint).

Michal

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel




___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


--
SMILE 

20 rue des Jardins
92600 Asnières-sur-Seine


*Jérémy ROSEN*
Architecte technique
Responsable de l'expertise Smile-ECS

email jeremy.ro...@smile.fr 
phone +33141402967
url http://www.smile.eu

Twitter  Facebook 
 LinkedIn 
 Github 




Découvrez l’univers Smile, rendez-vous sur smile.eu 



eco Pour la planète, n'imprimez ce mail que si c'est nécessaire
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-02-26 Thread 林自均
Hi both Michal,

Thank you for the quick responses! I think I will keep on using the tedious
PartOf= directive.

However, may I ask why ConsistsOf= is readonly? If I can use it in my
"my-apps.target", that would be great.

John Lin

Michal Koutný  於 2018年2月26日 週一 下午7:28寫道:

>
>
> On 02/26/2018 11:08 AM, Michal Sekletar wrote:
> > Unfortunately, we don't have a dependency (AFAIK) that only propagates
> > stop actions.
> FTR (not helpful for the original problem), there exists ConsistsOf= as
> an inverse of PartOf= dependency. However, it's read only currently (or
> strictly speaking, writable through the PartOf= endpoint).
>
> Michal
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a target unit to start & stop a group of services

2018-02-26 Thread Michal Koutný


On 02/26/2018 11:08 AM, Michal Sekletar wrote:
> Unfortunately, we don't have a dependency (AFAIK) that only propagates
> stop actions.
FTR (not helpful for the original problem), there exists ConsistsOf= as
an inverse of PartOf= dependency. However, it's read only currently (or
strictly speaking, writable through the PartOf= endpoint).

Michal



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] Create a target unit to start & stop a group of services

2018-02-26 Thread Michal Sekletar
On Mon, Feb 26, 2018 at 10:24 AM, 林自均  wrote:

> However, it is a little bit tedious to write drop-ins for each service
> units. Is there a directive for "my-apps.target" to propagate "stop"
> operation to the 3 services? I was expecting something like
> "PropagateStopTo=docker.service sshd.service mongodb.service".

I agree that preparation steps are tedious for your scenario, but this
is because the original use-case behind PartOf was a bit different. We
needed a way to stop a group of services at the same time. Think about
foo.target and then imagine a lot of instances of foo@.service which
all have PartOf=foo.target (because of configuration in the template
unit file). Previously you couldn't really stop the instances with a
single command.

Unfortunately, we don't have a dependency (AFAIK) that only propagates
stop actions.

Michal
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Create a target unit to start & stop a group of services

2018-02-26 Thread 林自均
Hi folks,

I would like to create a target unit to start and stop a group of services.
For example, I want a "my-apps.target" to start and stop "docker.service",
"sshd.service" and "mongodb.service". Here are my units and drop-ins:

# /etc/systemd/system/my-apps.target
[Unit]
Wants=docker.service sshd.service mongodb.service # for starting

# /etc/systemd/system/docker.service.d/my-apps.conf
[Unit]
PartOf=my-apps.target # for stopping

And the drop-ins for "sshd.service" and "mongodb.service" are similar.

Then I can use "systemctl start my-apps.target" and "systemctl stop
my-apps.target" to start and stop the 3 services.

However, it is a little bit tedious to write drop-ins for each service
units. Is there a directive for "my-apps.target" to propagate "stop"
operation to the 3 services? I was expecting something like
"PropagateStopTo=docker.service sshd.service mongodb.service".

Thanks!

John Lin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel