Re: Restarting dependant services

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Thu, 06 Jul 2017 14:24:08 +0000

>I need to ensure that if A service is down (crash or exit) all
>dependant B
>services will be restarted.

  In general, B processes will themselves die (and be restarted by their
supervisors) if they can't find a resource that is provided by service
A,
so you don't need to do anything manually.
  If it's not the case, what happens with B processes? Do they keep
working with stale or incorrect information? That is a problem that the
maintainers of B need to fix.


>Right now if I kill -9 <pid A> all B services stay alive.

  If they can't work properly without A, they should detect A's death
and die. If they don't, they should put themselves into a degraded
state that still works.

  If B processes do not die, it means B services can survive until the
A process comes back up, and resume normal operation at that point.
It's a valid pattern.

  But if you want to ensure process dependency, i.e. B processes must die
when the A process dies, as opposed to service dependency, then you need
to enforce that in run and/or finish scripts. The simplest way to do
that would probably to perform "s6-svc -t B" for all your B services
in A's finish script, or in A's run script, as you prefer. The former
will kill B processes when A dies, the latter when it comes back up.

  I generally don't recommend this because it makes your services more
fragile instead of more resilient, but if it's what you want, adding
s6-svc commands to run/finish scripts is the way to do it.

--
  Laurent
Received on Thu Jul 06 2017 - 14:24:08 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC