Create a target unit to start & stop a group of services

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <zbyszek at in.waw.pl> æ?¼ 2018å¹´3æ??7æ?¥ é?±ä¸? ä¸?å??8:48寫é??ï¼?

> On Tue, Mar 06, 2018 at 03:07:30AM +0000, æ??è?ªå?? wrote:
> > Anyone?
> >
> > John Lin
> >
> > æ??è?ªå?? <johnlinp at gmail.com> æ?¼ 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180308/bf5b7c98/attachment.html>


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux