[systemd-devel] Behavior of BindsTo when stopping a service
Amit Saha
amitsaha.in at gmail.com
Sat Jan 27 23:11:41 UTC 2018
On Sun, 28 Jan 2018 at 6:22 am, Andrei Borzenkov <arvidjaar at gmail.com>
wrote:
> 26.01.2018 05:11, Amit Saha пишет:
> > Hello,
> >
> > I have a systemd service - drainconnections which I want to to make sure
> > finishes stopping before systemd starts stopping another service. What I
> > also want is to if I stop supervisord service, drainconnections should be
> > stopped first.
> >
> > It seems like BindsTo is what I need for establishing the coupling
> between
> > the two units.
>
> If your description of services relationship is accurate and complete,
> BindsTo is too strong here; you really need just PartsOf.
Thanks. PartOf looks like something more suitable. Would having PartOf in
supervisord obey the before after relationship setup by drainconnections
service?
I will give it a shot.
>
>
> > The following unit file describes drainconnections:
> >
> >
> > [Unit]
> > Description=Drain Connections
> > After=supervisord.service
> > BindsTo=supervisord.service
> >
> > [Service]
> > Type=oneshot
> > RemainAfterExit=True
> > ExecStart=/bin/true
>
> I think recent sytsemd relaxes requirement, so you can omit ExecStart here.
Thanks.
>
>
> > ExecStop=/usr/bin/touch /var/shuttingdown1
> > ExecStop=/usr/bin/sleep 60
> > ExecStop=/usr/bin/touch /var/shuttingdown2
> >
> > [Install]
> > WantedBy=multi-user.target
> >
> >
> > In addition, I also needed to add BindsTo=drainconnections to the
> > supervisord service.
> >
>
> This will create dependency loop with your unit definition shown above.
Wouldn’t the Before/After take care of breaking the dependency loop? That
seems to be what I observed.
>
> > Things work as desired for me considering the above configuration.
> >
> > Am I on the right track here? Thanks in advance.
> >
> > Best Wishes,
> > Amit.
> >
> >
> >
> > _______________________________________________
> > systemd-devel mailing list
> > systemd-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180127/53d58a35/attachment.html>
More information about the systemd-devel
mailing list