Re: How does exec work with systemd?
Steve Litt <slitt@troubleshooters.com> writes:
>The only thing is, Daemontools has no way of telling it which order to
>load things, so, for instance, I'll need to load the dns server
>before Dovecot and Apache, so the dns server will continue to be
>loaded by the init system.
I've been using runit for some time, which is a clone of daemontools
(from the time when DJB licensing was an issue). I have a small set of
shell functions in /lib/sv/utils.sh that I source in my run scripts.
Some of these are:
temp_fail() { sleep 5; exit ${1:-1}; }
depend_on_net() {
[ -n "$1" ] || return 0
ip addr show dev "$1" 2>&- | grep -qs "inet.*$1" || temp_fail
return 0
}
depend_on_ip_addr() {
[ -n "$1" ] || return 0
[ "$1" = '0.0.0.0' ] && return 0
ip addr show 2>&- | grep -qs "inet $1[/ ]" || temp_fail
return 0
}
depend_on_sv() {
[ -n "$1" ] || return 0
sv status "$1" | grep -qs "^run:" || temp_fail 2
return 0
}
These allow you to put commands such as:
depend_on_sv apache
depend_on_net eth0
in the run script. If the dependency is not yet ready, it will sleep for
5 seconds and exit, leaving runsv to restart it to try again.
These will need to be adapted for daemontools, but the principle is the same.
Reply to: