Re: Application supervisor: sync point manager

From: Laurent Bercot <>
Date: Fri, 19 Aug 2016 18:28:25 +0200

On 19/08/2016 17:23, Lionel Van Bemten wrote:
> But there
> is one exception: all applications must wait for the spm to be ready
> before being started. I see several possibilities:

  You have a dependency graph. This is normally solved by a service manager.
So my advice, in all genericity, would be to use s6-rc or anopa to take care
of your services. It would go like this:
  - define a service database containing only longruns (i.e. daemons to be
supervised). spm depends on nothing, but all other applications depend on spm.
  - add a bundle "all-apps" containing all your apps
  - compile the service database, install it on your system
  - at boot time, run something like "s6-rc-init /service && s6-rc -u change
all-apps". That will start spm first, and then all your applications once spm
is up and ready, which is exactly what you want.

  If you're planning to add more services to be supervised, with more
dependencies between services, and especially if you're planning to add
oneshots (i.e. programs that must be run once to satisfy dependencies but
do not leave a daemon to supervise), then it's definitely the approach I'd
recommend, because it's the clean way of handling dependencies between

  However, as long as you only have longruns and your dependency graph is
as simple as "spm first, and then everything else", using a full-fledged
service manager is probably overkill - and you can get by with manual
invocations of the notification primitives.

  Your 1. and 2. approaches are both valid. In 2., the race condition is so
tiny that you'll never hit it, and even if you do, it just means that s6-svwait will fail. If you replace "foreground" with "if", your app run
script will exit, and be restarted, if s6-svwait fails: that solves your
  I would recommend 1. though, because it's clean, and it's also the way
that s6-rc and anopa internally work, so if someday you want to switch,
you'll already have the control flow in place:

  - Have a scandir with links to your servicedirs all containing down files,
and start s6-svscan on it.
  - (There's a negligible race condition here; if you want to avoid it,
there are various possible tricks to wait until all the s6-supervise processes
have been started. One of those tricks is to wait until ":>supervise/control"
unblocks for every service directory.)
  - Start spm and wait for it to be ready: s6-svc -uwU /service/spm
  - Start everything else: for i in /service/* ; do s6-svc -u $i ; done
  - Remove the down files. (So the services get restarted even if their
supervisor dies.)


Received on Fri Aug 19 2016 - 16:28:25 UTC

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