[systemd-devel] Behavior of BindsTo when stopping a service

Amit Saha amitsaha.in at gmail.com
Fri Jan 26 02:11:40 UTC 2018


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. The following unit file describes drainconnections:


[Unit]
Description=Drain Connections
After=supervisord.service
BindsTo=supervisord.service

[Service]
Type=oneshot
RemainAfterExit=True
ExecStart=/bin/true
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.

Things work as desired for me considering the above configuration.

Am I on the right track here? Thanks in advance.

Best Wishes,
Amit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180126/5d83f385/attachment.html>


More information about the systemd-devel mailing list