Upstart job for BIND9
alex at net-me.net
Thu Nov 29 12:03:12 UTC 2012
The script in my original question (it's in the P.S. at the bottom of my
first mail) seem to work for me. It does not cover all the extra logic of
the ubuntu default init.d/bind9, but I personally don't need that (ubuntu
script may update resolv.conf, and also checks if there's a network
But now I realised that it's all much simpler. "named -f" runs bind in the
foreground (does not daemonise) and that's just what upstart needs. Here's
my new upstart job file, place it to /etc/init/bind.conf (I can't decide
which one is better: bind.conf, bind9.conf or named.conf :)
#UPSTART JOB FOR BIND9
start on runlevel 
stop on runlevel [!2345]
# dirs under /var/run can go away on reboots.
mkdir -p /var/run/named
chmod 775 /var/run/named
chown root:bind /var/run/named >/dev/null 2>&1 || true
#Add bind command-line options below
exec /usr/sbin/named -f -u bind
pre-stop exec rndc stop
post-stop exec logger -p user.warning -t upstart-bind "bind stopped"
respawn limit 3 10
kill timeout 30
It will run bind on runlevels 2345, stop bind on other runlevels, but the
most important - respawn it once it stops with one it's famous assertion
failures :). It also logs a warning to syslog when bind closes (I use
something like that to send me an email).
If someone wants to use the job, here's some instructions: 1. don't forget
to disable the init.d script, or you may end up with two conflicting nameds
- the easiest way is sudo chmod -x /etc/init.d/bind9 . 2. As with any
upstart job, to stop bind you now do "stop bind", to start - "start bind",
and there's also "restart bind". If you have your fancy stuff in
/etc/defaults/bind9, just add at to the end of the "exec" line.
It seems to work for me, but I can't say it's really tested. Comments and
improvements are greatly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the bind-users