#!/sbin/openrc-run
name="DNSDist"
description="DNSdist - dns loadbalancer"
config=/etc/dnsdist/dnsdist.conf
pidfile=/run/dnsdist.pid
CMD=/usr/bin/dnsdist

OPTS=" -u pdns -g pdns --supervised --config ${config}"

depend() {
        need net
        after firewall
}

start() {
        ebegin "Starting DNSdist"
        limits
        start-stop-daemon --background --start --make-pidfile --pidfile ${pidfile} --quiet --exec ${CMD} \
                -- ${OPTS}
        eend $?
}

stop() {
        ebegin "Stopping DNSdist"
        start-stop-daemon --quiet --stop \
                --pidfile ${pidfile} \
                --retry 20 \
        eend $?
}

limits() {
        ulimit -n 16384
	ulimit -l unlimited
}
