From 6e6c61180f6dfc0fd075cb81b175560f7de8d68a Mon Sep 17 00:00:00 2001 From: f Date: Mon, 14 Mar 2022 18:14:24 -0300 Subject: [PATCH] mmmonit --- .woodpecker.yml | 4 +--- Dockerfile | 10 +++++++++- mmmonitd.sh | 21 +++++++++++++++++++++ monit.conf | 3 +++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100755 mmmonitd.sh create mode 100644 monit.conf diff --git a/.woodpecker.yml b/.woodpecker.yml index 6ba53d3..8ed7ae5 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -2,7 +2,7 @@ pipeline: publish: image: plugins/docker registry: registry.nulo.in - repo: registry.nulo.in/sutty/CHANGEME + repo: registry.nulo.in/sutty/mmmonit tags: - ${ALPINE_VERSION} - latest @@ -18,5 +18,3 @@ pipeline: matrix: ALPINE_VERSION: - 3.15.0 - - 3.14.3 - - 3.13.7 diff --git a/Dockerfile b/Dockerfile index d93a8d9..a249bfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,12 @@ -ARG ALPINE_VERSION=3.13.6 +ARG ALPINE_VERSION=3.15.0 ARG BASE_IMAGE=sutty/monit FROM ${BASE_IMAGE}:${ALPINE_VERSION} MAINTAINER "f " + +RUN apk add --no-cache mmmonit daemonize + +COPY ./monit.conf /etc/monit.d/mmmonit.conf +COPY ./mmmonitd.sh /usr/local/bin/mmmonitd + +EXPOSE 3000/tcp +VOLUME /srv diff --git a/mmmonitd.sh b/mmmonitd.sh new file mode 100755 index 0000000..572a3bd --- /dev/null +++ b/mmmonitd.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +dir=${DIR:-/srv} +pid=/run/mmmonit.pid +# TODO: Log to syslog +log=${dir}/mmmonit.log +usr=${USER:-nobody} + +case $1 in + start) + chown -R ${usr}:${usr} ${dir} + install -dm 750 -o ${usr} -g ${usr} ${dir}/storage ${dir}/storage/xml + daemonize -a -e ${log} -o ${log} -c ${dir} -p ${pid} -l ${pid} -u ${usr} /usr/bin/mmmonit + ;; + stop) + test -f ${pid} || exit 0 + + cat ${pid} | xargs -r kill + ;; +esac diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..cbfdde1 --- /dev/null +++ b/monit.conf @@ -0,0 +1,3 @@ +check process mmmonit with pidfile /run/mmmonit.pid + start program = "/usr/local/bin/mmmonitd start" + stop program = "/usr/local/bin/mmmonitd stop"