On Tue, 11 Oct 2016 11:53:38 +0200 Jan Bramkamp <cr...@rlwinm.de> wrote:
> Runit doesn't track dependencies directly, but it can handle them. > This is done by calling sv start $DEP_1 $DEP_2 etc. in the ./run > script. I've always done it differently, as shown in this run script: ================================================ #!/bin/sh if test_of_readiness_of_dep1; then exec this_daemon fi sleep 1 ================================================ So if $DEP_1 isn't ready, $THIS_DAEMON waits a second and then fails and is soon tried again. For a dependency that takes huge amounts of time, like dhcpcd, that sleep might be 15 instead of 1. Your method is obviously more efficient and straightforward than mine. My method theoretically could act like a bunch of ping pong balls on a bunch of set mousetraps, although in practice I've never seen any evidence of that. Your method sets off dependencies consecutively rather than trial and error, and would seem to be superior, with two exceptions: 1) My method can be used to test for any arbitrary definition of the dependency being "ready". For instance, my sshd service could run only after a successful ping of 8.8.8.8 or of google.com, thereby proving the network is up all the way to the Internet. This is much more specific than merely testing whether the networking system is running. 2) My method refuses to run $THIS_DAEMON if $DEP_1 is not functional, rather than starting $DEP_1 and assuming it will start correctly, instantly. My method refuses to run a daemon when its dependencies have serious problems. I'm wondering if our methods could be combined: ================================================ #!/bin/sh sv start $DEP_1 sleep $APPROPRIATE_SECONDS if test_of_readiness_of_dep1; then exec this_daemon fi sleep 1 ================================================ In the preceding, $APPROPRIATE_SECONDS is probably a small fraction like 0.1: Just enough time for $DEP_1 to become ready to do its job. SteveT Steve Litt September 2016 featured book: Twenty Eight Tales of Troubleshooting http://www.troubleshooters.com/28