diff --git a/Dockerfile b/Dockerfile index 44dd8aa..af32ad7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,11 @@ ARG BASE_IMAGE=gitea.nulo.in/sutty/monit FROM ${BASE_IMAGE}:${ALPINE_VERSION} MAINTAINER "f " ARG KNOT_VERSION=3.1.8 +ENV SUTTYNS_FLAGS -RUN apk add --no-cache knot~${KNOT_VERSION} +RUN apk add --no-cache knot~${KNOT_VERSION} suttyns COPY ./monit.conf /etc/monit.d/knot.conf +COPY ./suttynsd.sh /usr/local/bin/suttynsd EXPOSE 53 EXPOSE 53/udp diff --git a/monit.conf b/monit.conf index cd5d961..6937009 100644 --- a/monit.conf +++ b/monit.conf @@ -4,3 +4,10 @@ check process knot with pidfile /tmp/knot.pid if 5 restarts within 8 cycles then alert if failed port 53 type udp protocol dns for 3 times within 5 cycles then restart if failed port 53 type tcp protocol dns for 3 times within 5 cycles then restart + +check process suttyns with pidfile /tmp/suttyns.pid + start program = "/usr/local/bin/suttynsd start" + stop program = "/usr/local/bin/suttynsd stop" + if 5 restarts within 8 cycles then alert + if failed port 53535 type udp protocol dns for 3 times within 5 cycles then restart + if failed port 53535 type tcp protocol dns for 3 times within 5 cycles then restart diff --git a/suttynsd.sh b/suttynsd.sh new file mode 100755 index 0000000..8616a9a --- /dev/null +++ b/suttynsd.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +pid=/tmp/suttyns.pid + +case $1 in + start) + test -f $pid && exit 0 + + daemonize -p $pid -u nobody /usr/local/bin/syslogize /usr/bin/suttyns $SUTTYNS_FLAGS + ;; + stop) + test -f $pid || exit 0 + + cat $pid | xargs kill + rm $pid + + ;; +esac