mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-18 10:59:00 +02:00
healthcheck testing
This commit is contained in:
@@ -50,10 +50,12 @@ COPY scripts/iobroker_startup.sh iobroker_startup.sh
|
|||||||
COPY scripts/setup_avahi.sh setup_avahi.sh
|
COPY scripts/setup_avahi.sh setup_avahi.sh
|
||||||
COPY scripts/setup_packages.sh setup_packages.sh
|
COPY scripts/setup_packages.sh setup_packages.sh
|
||||||
COPY scripts/setup_zwave.sh setup_zwave.sh
|
COPY scripts/setup_zwave.sh setup_zwave.sh
|
||||||
|
COPY scripts/healthcheck.sh healthcheck.sh
|
||||||
RUN chmod +x iobroker_startup.sh \
|
RUN chmod +x iobroker_startup.sh \
|
||||||
&& chmod +x setup_avahi.sh \
|
&& chmod +x setup_avahi.sh \
|
||||||
&& chmod +x setup_packages.sh \
|
&& chmod +x setup_packages.sh \
|
||||||
&& chmod +x setup_zwave.sh
|
&& chmod +x setup_zwave.sh \
|
||||||
|
&& chmod +x healthcheck.sh
|
||||||
WORKDIR /opt/userscripts/
|
WORKDIR /opt/userscripts/
|
||||||
COPY scripts/userscript_firststart_example.sh userscript_firststart_example.sh
|
COPY scripts/userscript_firststart_example.sh userscript_firststart_example.sh
|
||||||
COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh
|
COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh
|
||||||
@@ -62,7 +64,9 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh
|
|||||||
WORKDIR /
|
WORKDIR /
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& curl -sL https://iobroker.net/install.sh | bash - \
|
&& curl -sL https://iobroker.net/install.sh | bash - \
|
||||||
&& echo $(hostname) > /opt/iobroker/.install_host \
|
&& mkdir -p /opt/iobroker/.docker_config/ \
|
||||||
|
&& echo $(hostname) > /opt/iobroker/.docker_config/.install_host \
|
||||||
|
&& echo "starting" > /opt/iobroker/.docker_config/.healthcheck \
|
||||||
&& echo $(hostname) > /opt/.firstrun \
|
&& echo $(hostname) > /opt/.firstrun \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
@@ -89,5 +93,9 @@ ENV DEBIAN_FRONTEND="teletype" \
|
|||||||
SETUID=1000 \
|
SETUID=1000 \
|
||||||
TZ="Europe/Berlin"
|
TZ="Europe/Berlin"
|
||||||
|
|
||||||
|
# healthcheck
|
||||||
|
HEALTHCHECK --interval=15s --timeout=5s --retries=5 \
|
||||||
|
CMD ["/bin/bash", "-c", "/opt/scripts/healthcheck.sh"]
|
||||||
|
|
||||||
# Run startup-script
|
# Run startup-script
|
||||||
ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"]
|
ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"]
|
||||||
|
|||||||
15
amd64/scripts/healthcheck.sh
Normal file
15
amd64/scripts/healthcheck.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script checks health of running container
|
||||||
|
|
||||||
|
if [ "$(cat /opt/iobroker/.docker_config/.healthcheck)" == "starting" ] || [ "$(cat /opt/iobroker/.docker_config/.healthcheck)" == "maintenance" ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ "ps -fe|grep "[i]obroker.js-controller"|awk '{print $2}'" != "" ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 1
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setting healthcheck status to "starting"
|
||||||
|
echo "starting" > /opt/iobroker/.docker_config/.healthcheck
|
||||||
|
|
||||||
# Reading ENV
|
# Reading ENV
|
||||||
adminport=$IOB_ADMINPORT
|
adminport=$IOB_ADMINPORT
|
||||||
avahi=$AVAHI
|
avahi=$AVAHI
|
||||||
@@ -16,6 +19,23 @@ statesdbtype=$IOB_STATESDB_TYPE
|
|||||||
usbdevices=$USBDEVICES
|
usbdevices=$USBDEVICES
|
||||||
zwave=$ZWAVE
|
zwave=$ZWAVE
|
||||||
|
|
||||||
|
# Writing necessary ENVs to /opt/iobroker/.docker_config/container.config for using it in other scripts
|
||||||
|
|
||||||
|
echo '# Simple config file to store ENVs' > /opt/iobroker/.docker_config/container.config
|
||||||
|
echo ' ' >> /opt/iobroker/.docker_config/container.config
|
||||||
|
if [ "$multihost" = "" ]
|
||||||
|
then
|
||||||
|
echo "multihost=master" >> /opt/iobroker/.docker_config/container.config
|
||||||
|
else
|
||||||
|
echo "multihost=$multihost" >> /opt/iobroker/.docker_config/container.config
|
||||||
|
fi
|
||||||
|
if [ "$adminport" = "" ]
|
||||||
|
then
|
||||||
|
echo "adminport=8081" >> /opt/iobroker/.docker_config/container.config
|
||||||
|
else
|
||||||
|
echo "adminport=$adminport" >> /opt/iobroker/.docker_config/container.config
|
||||||
|
fi
|
||||||
|
|
||||||
# Getting date and time for logging
|
# Getting date and time for logging
|
||||||
dati=`date '+%Y-%m-%d %H:%M:%S'`
|
dati=`date '+%Y-%m-%d %H:%M:%S'`
|
||||||
|
|
||||||
@@ -173,12 +193,12 @@ echo "Done."
|
|||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
# Checking for first run of a new installation and renaming ioBroker
|
# Checking for first run of a new installation and renaming ioBroker
|
||||||
if [ -f /opt/iobroker/.install_host ]
|
if [ -f /opt/iobroker/.docker_config/.install_host ]
|
||||||
then
|
then
|
||||||
echo "Looks like this is a new and empty installation of ioBroker."
|
echo "Looks like this is a new and empty installation of ioBroker."
|
||||||
echo "Hostname needs to be updated to " $(hostname)"..."
|
echo "Hostname needs to be updated to " $(hostname)"..."
|
||||||
bash iobroker host $(cat /opt/iobroker/.install_host)
|
bash iobroker host $(cat /opt/iobroker/.docker_config/.install_host)
|
||||||
rm -f /opt/iobroker/.install_host
|
rm -f /opt/iobroker/.docker_config/.install_host
|
||||||
echo "Done."
|
echo "Done."
|
||||||
echo ' '
|
echo ' '
|
||||||
elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ]
|
elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ]
|
||||||
@@ -466,6 +486,9 @@ echo ' '
|
|||||||
echo "Starting ioBroker..."
|
echo "Starting ioBroker..."
|
||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
|
# Setting healthcheck status to "running"
|
||||||
|
echo "running" > /opt/iobroker/.docker_config/.healthcheck
|
||||||
|
|
||||||
# Function for graceful shutdown by SIGTERM signal
|
# Function for graceful shutdown by SIGTERM signal
|
||||||
shut_down() {
|
shut_down() {
|
||||||
echo ' '
|
echo ' '
|
||||||
|
|||||||
Reference in New Issue
Block a user