mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
commit
1e25e36ce6
195 files changed
+152301
No files matched your search
+23
@@ -0,0 +1,23 @@
|
||||
FROM containrrr/watchtower:latest
|
||||
|
||||
USER root
|
||||
|
||||
RUN apk add --no-cache python3 py3-pip
|
||||
|
||||
WORKDIR /opt/uptime-bot
|
||||
|
||||
COPY requirements.txt /opt/uptime-bot/requirements.txt
|
||||
RUN pip3 install --no-cache-dir -r /opt/uptime-bot/requirements.txt
|
||||
|
||||
COPY uptime-bot.py /opt/uptime-bot/uptime-bot.py
|
||||
COPY config.yml /opt/uptime-bot/config.yml
|
||||
COPY container-monitor-map.yaml /opt/uptime-bot/container-monitor-map.yaml
|
||||
COPY watchtower-embedded/start-watchtower-with-uptime-bot.sh /usr/local/bin/start-watchtower-with-uptime-bot.sh
|
||||
|
||||
RUN chmod +x /usr/local/bin/start-watchtower-with-uptime-bot.sh
|
||||
|
||||
ENV UPTIME_BOT_CONFIG=/opt/uptime-bot/config.yml
|
||||
ENV UPTIME_BOT_MAP=/opt/uptime-bot/container-monitor-map.yaml
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/start-watchtower-with-uptime-bot.sh"]
|
||||
CMD ["--interval", "300", "--cleanup"]
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
BOT_SCRIPT="/opt/uptime-bot/uptime-bot.py"
|
||||
WATCHTOWER_BIN="/watchtower"
|
||||
|
||||
if [ ! -x "${WATCHTOWER_BIN}" ]; then
|
||||
echo "[ERROR] watchtower binary not found at ${WATCHTOWER_BIN}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${BOT_SCRIPT}" ]; then
|
||||
echo "[ERROR] bot script not found at ${BOT_SCRIPT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 "${BOT_SCRIPT}" &
|
||||
BOT_PID=$!
|
||||
|
||||
"${WATCHTOWER_BIN}" "$@" &
|
||||
WT_PID=$!
|
||||
|
||||
shutdown() {
|
||||
kill "${BOT_PID}" 2>/dev/null || true
|
||||
kill "${WT_PID}" 2>/dev/null || true
|
||||
wait "${BOT_PID}" 2>/dev/null || true
|
||||
wait "${WT_PID}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
trap shutdown INT TERM
|
||||
|
||||
while :; do
|
||||
if ! kill -0 "${BOT_PID}" 2>/dev/null; then
|
||||
echo "[ERROR] uptime bot exited; stopping watchtower" >&2
|
||||
kill "${WT_PID}" 2>/dev/null || true
|
||||
wait "${WT_PID}" 2>/dev/null || true
|
||||
wait "${BOT_PID}" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! kill -0 "${WT_PID}" 2>/dev/null; then
|
||||
echo "[ERROR] watchtower exited; stopping uptime bot" >&2
|
||||
kill "${BOT_PID}" 2>/dev/null || true
|
||||
wait "${BOT_PID}" 2>/dev/null || true
|
||||
wait "${WT_PID}" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
done
|
||||
Reference in new issue
Block a user