How to supervise an early process

From: Steve Litt <slitt_at_troubleshooters.com>
Date: Sun, 19 Jun 2016 12:02:43 -0400

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
Received on Sun Jun 19 2016 - 16:02:43 UTC

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