[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Init system in Lua
- From: Jakub Piotr Cłapa <jpc-ml@...>
- Date: Sun, 20 Nov 2011 02:07:28 +0100
On 18.11.11 23:32, clemens fischer wrote:
You might want to look at runit[1], s6[2] or the daemontools[3], which
implement managing what they call "services". A supervisor sends
signals to a service. If the services directory structure has
a subdirectory called ./log, the "run" program in it, which often is
a regular shell script, execs into a logger. The supervisor sets up
a pipe from the services stdout to the loggers stdin and tries its best
to keep it even when either the service or the logger crashes. The
supervisor also restarts programs after a crash.
I second that. The daemontools are really well thought out and worth
learning from. They offer lots of functionality using no magic and
schockingly low amounts of code. Even if you find these systems a little
weird you should still try to learn how they work so you can design
something better.
I know that being better than the standard tons of crappy SysVinit
scripts is nice but why stop there?
These systems can be used as unix process 1 ("init") and they don't need
dependency checking. If some service needs another one early, it will
crash, of course, but it will get restarted. As long as the dependency
graph contains no cycles, the system stabilizes pretty fast. S6
implements a notifier which can be used for dependency tracking. Runit
implements "guarding" scripts which can be used for housekeeping.
Dependency tracking can be done by a small executable which waits for
the services that were passed to it to start up. Or you can keep the
dependencies as symlinks in a subfolder and make the supervisor respect
them. Using inotify or some other file monitoring system for this could
replace lots of ad-hoc IPC.
Bourne shell is not the best thing for running Unix services but before
deciding if Lua is you may check out the rc shell (from Plan 9 but it
has ports to normal old Unix). If want something even simpler then
execline may be worth a shot.
--
regards,
Jakub Piotr Cłapa