Upstart job for BIND9

Anand Buddhdev anandb at
Tue Dec 4 23:04:06 UTC 2012

On 29/11/2012 11:25, Alexander Gurvitz wrote:

Hi Alexander,

> I'm trying to run a bind9 from an upstart job instead of an init.d script.
> I'm a bit confused if I should "expect fork" or "expect daemon". It seems
> to work with "expect fork", though somehow I don't feel convinced.

Actually, you don't need either. If you start BIND with the "-f" option,
it remains in the foreground, and this is the best way to run daemons
under upstart (and also OSX's launchd). See below.

> (Upstart must know how the daemon forks - if it forks once,
> "expect fork" should be specified, and if a daemon forks twice,
> it should be "expect daemon". Then upstart will wait for that forkings and
> will monitor the final PID).
> Thanks in advance,
> Alexander Gurvitz,
> P.S My /etc/init/bind.conf:
> start on runlevel [2345]
> stop on runlevel [!2345]
> pre-start script
>         # 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
> end script
> exec /usr/sbin/named -u bind

Replace this with "exec /usr/sbin/named -f -u bind"

> pre-stop exec rndc stop -p
> post-stop exec logger -p user.warning -t upstart-bind "bind stopped"
> expect fork

Remove this "expect fork".

> respawn
> respawn limit 3 10
> kill timeout 30
> console none


Anand Buddhdev

More information about the bind-users mailing list