Re: Thoughts on "First Class Services"

From: Avery Payne <>
Date: Tue, 28 Apr 2015 07:57:31 -0700

On 4/28/2015 7:18 AM, bougyman wrote:
> On Tue, Apr 28, 2015 at 8:38 AM, Avery Payne <> wrote:
> I guess I don't know what this means, in practice. My child services
> generally know about the
> parent in their ./run script and the parent (sometimes) has to know
> about the children in his
> ./finish script.

I do the opposite using an optional flag that is initially disabled at
installation. The short version is, using
parent-only-knows-child-needs makes the dependency chains self-organizing.

The long version is that, in supervision-scripts, each service (parent)
has a list of immediate needs to be met (children). It attempts to
start each child in a subdirectory named ./needs (coincidentally, anopa
uses a compatible arrangement with ./needs). Each child is iterated
through and checked to see if it is running; if it is not running, it is
started, and the next child examined, until all children are started.
If all children start, the parent proceeds to start. If a child fails,
the parent writes a message to its log saying "my child X failed" and
proceeds to spawn-loop.

As each child starts, if there is a ./needs in the child, it repeats the
same behavior as the parent, calling other grandchildren and then
eventually starting once all of its own dependencies are running. The
script is the same for parent and children alike, so the behavior is
meant to be consistent. The process is repeated for each grand-child,
great-grand-child, etc. until the lowest dependencies are running,
causing the entire dependency "tree" to be traversed. This also means
the "tree" can be a "chain" or any other arrangement. "Leaf nodes" of
that tree can be called more than once without harm because if they were
already launched elsewhere, the start-up of that node is skipped. And
finally, I don't need to track the entire state of the tree, I only need
to track what children are needed for any given parent, making the
entire thing self-organizing, while keeping it simple.

> None of the parents know anything about their children.
I'm just doing it backwards. If I had definitions for postgresql and
pgbouncer, I would only add the following soft links:


That's pretty much it. Nothing else would need to be added to ./run for
each service.

> I'd like to see the difference in a code example. I haven't had a
> chance to dig in to anopa yet enough to see how they couple it mouse
> loosely. Tj

Here's the current version of, with dependency support baked in:
Received on Tue Apr 28 2015 - 14:57:31 UTC

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