55 lines
2.5 KiB
Plaintext
55 lines
2.5 KiB
Plaintext
After some messing about, I've finished my dependency system for runit,
|
|
and am now using it to start up and shut down my machine. =)
|
|
|
|
I've hacked about on svwaitup and svwaitdown a little; the diff is
|
|
enclosed and is required to make the dependencies work. Summary of
|
|
changes:
|
|
* svwaitup has an option to retry (with a variable delay) if the
|
|
supervisor is not running or the service is not requested to be up.
|
|
This was needed as the dependencies are brought up in background
|
|
processes for parallelism, so the parent has to wait.
|
|
* svwaitdown has an option not to send the down command to services
|
|
(still defaults to doing so). This is needed for the inverse situation
|
|
of the above. =)
|
|
You need the previous patch I posted as well which creates the tools
|
|
svisup and svisdown.
|
|
|
|
The actual dependency management is done by having links in
|
|
servicedir/updeps that point to services which must be up first. The
|
|
reverse dependencies can be automatically generated by the enclosed
|
|
script svdepcalc, though at the moment it's really stupid and doesn't do
|
|
any kind of checking for cycles..etc.
|
|
|
|
Once the dependency links are there, svup and svdown will bring services
|
|
up and down in a way which obeys all dependency rules. The way I use it:
|
|
* All services are in a single directory; no pseudo-runlevels or
|
|
anything
|
|
* All services have a 'down' file to stop them starting.
|
|
* The /etc/runit/1 script runs svup in the background on a dummy service
|
|
which depends on everything I want to run (apache..etc).
|
|
* runsvdir starts and brings up the supervisors, and as it does so, svup
|
|
brings services up.
|
|
|
|
Once the machine is up you can use svup and svdown freely to start and
|
|
stop services in a way which follows the dependencies. Then, to shut
|
|
down:
|
|
|
|
* /etc/runit/3 runs 'for SRV in /service/*; do svdown $SRV; done' which
|
|
brings services down in line with dependencies. At least, if they
|
|
terminate properly. There is a timeout for services that don't. (they
|
|
are not killed at this stage)
|
|
* /etc/runit/3 runs svwaitdown -kx with a short timeout to clean up any
|
|
services which did not get terminated cleanly by the above
|
|
* Halt.
|
|
|
|
I make few promises about the actual correct functioning of these
|
|
scripts and strongly recommend that you have a good read of them (in
|
|
fact, it'd be nice if you did that anyway to give me some feedback).
|
|
They work for me on exactly one machine, and have been tested a bit on
|
|
some fake services as well, but that's not a *lot* of testing.. =)
|
|
|
|
Thanks in advance for any comments, and I hope that at least someone
|
|
finds this useful =)
|
|
|
|
Torne
|