Re: How to supervise an early process

2016-06-19 Thread Laurent Bercot

On 19/06/2016 18:02, Steve Litt wrote:

A big objection to most supervision type init systems is that for a
given process you must choose between early, like run from the rc
script(s) preceding running of the supervisor, and respawning
supervision.

I just thought of a theoretical hack to have both.


 Lots of people think of hacks. But hacks are a problem, not a solution;
they're the very problems that supervision was made to solve.

 The non-hackish solution is to have the supervisor start very early,
before any service; then you don't have to make that choice, because
every longrun can be supervised.
 That's what s6-linux-init and nosh do. It's a solved problem.

--
 Laurent



How to supervise an early process

2016-06-19 Thread Steve Litt
Hi all,

A big objection to most supervision type init systems is that for a
given process you must choose between early, like run from the rc
script(s) preceding running of the supervisor, and respawning
supervision.

I just thought of a theoretical hack to have both. 

Symlink to give the executable a new name. 

ln -s myapp myapp_sym

Run myapp_sym as early as you want in the rc file. Heck, run it in
the initramfs for all I care, and let it switch_root over. Then, in the
run script for any supervision suite, do this:

===
#!/bin/sh
if ps ax | grep myapp_sym; then
  killall myapp_sym
fi

exec myapp
===

Obviously, for some apps, you'll need to shut down a little more
gracefully than killall, but whatever way you need to shut down, you
just put it in the if statement or in a shellscript called from
within the if statement. 

This should work on daemontools, daemontools-encore, runit and s6. It
might run on more, but those four are the only ones I've used.

One of the outstanding benefits of supervision suites is how malleable
they are with a little imagination.

Thanks,

SteveT

Steve Litt
June 2016 featured book: Troubleshooting: Why Bother?
http://www.troubleshooters.com/twb