re-instate HEALTHCHECK

closes #24
This commit is contained in:
Jan-Piet Mens
2019-01-09 18:51:27 +01:00
parent a2d6847661
commit e59dd7f0dc
2 changed files with 36 additions and 0 deletions
+4
View File
@@ -6,6 +6,7 @@ MAINTAINER Malte Deiseroth <mdeiseroth88@gmail.com>
COPY entrypoint.sh /entrypoint.sh
COPY config.mk /config.mk
COPY recorder.conf /etc/default/recorder.conf
COPY recorder-health.sh /usr/local/sbin/recorder-health.sh
ENV VERSION=0.8.0
@@ -25,12 +26,15 @@ RUN apk add --no-cache --virtual .build-deps \
&& cd / \
&& chmod 755 /entrypoint.sh \
&& rm -rf /usr/local/source \
&& chmod 755 /usr/local/sbin/recorder-health.sh \
&& apk del .build-deps
VOLUME ["/store", "/config"]
COPY recorder.conf /config/recorder.conf
HEALTHCHECK CMD /usr/local/sbin/recorder-health.sh
EXPOSE 8083
ENTRYPOINT ["/entrypoint.sh"]
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
addr=`hostname`
port=8083
epoch=$(date +%s)
location=$(cat <<EOJSON
{
"_type": "location",
"tid": "pp",
"lat": 51.47879,
"lon": -0.010677,
"tst": $epoch
}
EOJSON
)
# POST location to ping/ping, ignoring output
curl -sSL --data "${location}" "http://${addr}:${port}/pub?u=ping&d=ping" > /dev/null
# obtain tst of ping/ping's last location
ret_epoch=$(curl -sSL http://${addr}:${port}/api/0/last --data "user=ping&device=ping" |
env python -c 'import sys, json; print json.load(sys.stdin)[0]["tst"];')
if [ $epoch -ne $ret_epoch ]; then
echo PANIC $epoch $ret_epoch
exit 1
else
echo OK
exit 0
fi