diff --git a/Dockerfile b/Dockerfile index 59c5898..3cc63af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,12 @@ FROM sutty/monit:latest MAINTAINER "f " + +ENV SRS_DOMAIN sutty.nl +ENV SRS_SECRET /etc/postsrsd.secret + +RUN apk add --no-cache postsrsd +COPY ./monit.conf /etc/monit.d/postsrsd.conf +COPY ./postsrsd.sh /usr/local/bin/postsrsd + +EXPOSE 10001 +EXPOSE 10002 diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..6c18e88 --- /dev/null +++ b/monit.conf @@ -0,0 +1,6 @@ +check process postsrsd with pidfile /tmp/postsrsd.pid + start program = "/usr/local/bin/postsrsd" + stop program = "/bin/sh -c 'cat /tmp/postsrsd.pid | xargs -r kill'" + + if failed port 10001 for 3 cycles then restart + if failed port 10002 for 3 cycles then restart diff --git a/postsrsd.sh b/postsrsd.sh new file mode 100755 index 0000000..7e56162 --- /dev/null +++ b/postsrsd.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +export SRS_PID_FILE=/tmp/postsrsd.pid + +case "$1" in + stop) + test -f "${SRS_PID_FILE}" && cat /tmp/postsrsd.pid | xargs -r kill + exit $? + ;; +esac + +test -n "${SRS_DOMAIN}" +test -n "${SRS_SECRET}" +test -f "${SRS_SECRET}" || dd if=/dev/urandom bs=18 count=1 status=none | base64 > "${SRS_SECRET}" + +/usr/sbin/postsrsd -e -D -l 0.0.0.0 -u postsrsd -4