healthcheck testing

This commit is contained in:
buanet
2020-07-27 21:46:15 +02:00
parent a2961abf67
commit f5f7e3f1ec
3 changed files with 51 additions and 5 deletions

View 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

View File

@@ -1,5 +1,8 @@
#!/bin/bash
# Setting healthcheck status to "starting"
echo "starting" > /opt/iobroker/.docker_config/.healthcheck
# Reading ENV
adminport=$IOB_ADMINPORT
avahi=$AVAHI
@@ -16,6 +19,23 @@ statesdbtype=$IOB_STATESDB_TYPE
usbdevices=$USBDEVICES
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
dati=`date '+%Y-%m-%d %H:%M:%S'`
@@ -173,12 +193,12 @@ echo "Done."
echo ' '
# 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
echo "Looks like this is a new and empty installation of ioBroker."
echo "Hostname needs to be updated to " $(hostname)"..."
bash iobroker host $(cat /opt/iobroker/.install_host)
rm -f /opt/iobroker/.install_host
bash iobroker host $(cat /opt/iobroker/.docker_config/.install_host)
rm -f /opt/iobroker/.docker_config/.install_host
echo "Done."
echo ' '
elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ]
@@ -466,6 +486,9 @@ echo ' '
echo "Starting ioBroker..."
echo ' '
# Setting healthcheck status to "running"
echo "running" > /opt/iobroker/.docker_config/.healthcheck
# Function for graceful shutdown by SIGTERM signal
shut_down() {
echo ' '