0
Here's my run script for dnsmasq:
#!/bin/ash
COMMAND="dnsmasq -k -C /etc/dnsmasq.conf"
DIR="$( cd "$( dirname -- "$0" )" >/dev/null 2>&1 && pwd )"
SERVICE_NAME=$(basename ${DIR})
exec ${COMMAND} 2>&1 | sed -e "s/^/\[${SERVICE_NAME}\]: /g"
dnsmasq starts correctly, but runit doesn't seem to track the process. The sed
process exits, the runsv
process exits and runsvdir
loses track of it:
$ ps auwxf
...
root 3264 0.0 0.0 756 4 ? S 15:22 0:00 | | | | \_ /sbin/runsvdir /services-enabled
root 3277 0.0 0.0 1640 4 ? S 15:22 0:00 | | | \_ /bin/ash ./run
nobody 3291 0.1 0.0 1000 4 ? S 15:22 0:00 | | | \_ dnsmasq -k -C /etc/dnsmasq.conf
...
So periodically runsvdir
tries to start it again:
$ ps auwxf
root 3264 0.0 0.0 756 4 ? S 15:22 0:00 | | | | \_ /sbin/runsvdir /services-enabled
root 3538 0.2 0.0 744 516 ? S 15:22 0:01 | | | | \_ runsv dnsmasq
root 10393 0.0 0.0 1640 4 ? S 15:28 0:00 | | | | \_ /bin/ash ./run
root 10397 41.0 0.0 980 4 ? R 15:28 0:00 | | | | \_ dnsmasq -k -C /etc/dnsmasq.conf
root 10398 0.0 0.0 1604 4 ? S 15:28 0:00 | | | | \_ sed -e s/^/\[dnsmasq\]: /g
root 3277 0.0 0.0 1640 4 ? S 15:22 0:00 | | | \_ /bin/ash ./run
nobody 3291 0.1 0.0 1000 4 ? S 15:22 0:00 | | | \_ dnsmasq -k -C /etc/dnsmasq.conf
This dies quickly because the original dnsmasq process already has port 53 open and so the cycle repeats every few seconds.
What's the right way to run dnsmasq
here so that this doesn't happen? -k
is theoretically meant to prevent dnsmasq
from daemonising but that doesn't seem to be working.
I've also tried
-d
but makes no difference. – Tom – 2019-08-17T14:59:20.340