From f836cd1fca93baacf58469e3c1240e9c3c176bf2 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 28 Jul 2020 19:25:44 +0200 Subject: [PATCH] testing and preparing beta --- README.md | 29 +++++++++++++++---- amd64/Dockerfile | 4 +-- amd64/scripts/healthcheck.sh | 4 +-- amd64/scripts/iobroker_startup.sh | 5 ++-- .../{maintenance-mode.sh => maintenance.sh} | 21 +++++++------- 5 files changed, 42 insertions(+), 21 deletions(-) rename amd64/scripts/{maintenance-mode.sh => maintenance.sh} (58%) diff --git a/README.md b/README.md index 87aac4e..fd5bfdd 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,20 @@ To get familiar with that feature try the following: Create a Container, mount a Details will follow soon. +### Healthcheck (beta) + +Since v5.0.2beta the image contains a simple Docker healthcheck. At the moment it only checks if js-controller is running inside the container and reports "healthy" or "unhealthy" to the Docker daemon. Further development is planned. + +Hint: As the Docker daemon itself gives no opportunity to automatically restart an unhealthy container you might want to setup some kind of "watchdog container" like this simple one: https://hub.docker.com/r/willfarrell/autoheal/ (works great so far!). + +### Maintenance script (beta) + +Within the implementation of the docker health check (above) some manual maintenance actions, like stopping ioBroker for upgrading js-controller, would cause the container to get "unhealthy" and may cause an external watchdog to automatically restart it. + +In this case you can use the new maintenance command line tool inside the container. By simply typing `maintenance on` it will activate some kind of "maintenance mode" and automatically stop ioBroker while the container stays healthy. + +After your maintenance is done just type `maintenance off`. Depending on the selected restart policy of your container the command will stop (and automatically restart) it. + ## Best practices ### Avoid using "latest" tag @@ -164,11 +178,16 @@ Thank you! ## Changelog -### v5.0.1beta (2020-07-01) -* fixing backup detection in startup script -* fixing permission issue on iobroker restored -* extended Logging -* optimize multihost support +### v5.0.2beta (2020-07-28) +* extend readme.md doku +* added maintenance script +* added container healthcheck +* fixed configuration procedure and logging for objects and states db setup +* v5.0.1beta (2020-07-01) + * fixing backup detection in startup script + * fixing permission issue on iobroker restored + * extended Logging + * optimize multihost support ### v5.0.0 (2020-06-29) * v4.2.4beta (2020-06-23) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index c956a1f..62a76c3 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -51,13 +51,13 @@ COPY scripts/setup_avahi.sh setup_avahi.sh COPY scripts/setup_packages.sh setup_packages.sh COPY scripts/setup_zwave.sh setup_zwave.sh COPY scripts/healthcheck.sh healthcheck.sh -COPY scripts/maintenance-mode.sh maintenance-mode.sh +COPY scripts/maintenance.sh maintenance.sh RUN chmod +x iobroker_startup.sh \ && chmod +x setup_avahi.sh \ && chmod +x setup_packages.sh \ && chmod +x setup_zwave.sh \ && chmod +x healthcheck.sh \ - && chmod +x maintenance-mode.sh + && chmod +x maintenance.sh WORKDIR /opt/userscripts/ COPY scripts/userscript_firststart_example.sh userscript_firststart_example.sh COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh diff --git a/amd64/scripts/healthcheck.sh b/amd64/scripts/healthcheck.sh index d54b7cc..dd7253e 100644 --- a/amd64/scripts/healthcheck.sh +++ b/amd64/scripts/healthcheck.sh @@ -8,7 +8,7 @@ then exit 0 elif [ "$(cat /opt/iobroker/.docker_config/.healthcheck)" == "maintenance" ] then - echo 'Health status: OK - Container running in maintenance mode.' + echo 'Health status: OK - Container is running in maintenance mode.' exit 0 elif [ "$(ps -fe|grep "[i]obroker.js-controller"|awk '{print $2}')" != "" ] then @@ -16,5 +16,5 @@ then exit 0 fi -echo 'Health status: !!! NOT OK !!! - Something went wrong. Please see Container Logs for more details.' +echo 'Health status: !!! NOT OK !!! - Something went wrong. Please see container logs for more details and/or try restarting the container.' exit 1 diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index d437bf9..4344f02 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -112,8 +112,9 @@ then fi if [ -f /opt/.firstrun ] then - echo "Registering maintenance-mode script as command." - echo "alias maintenance-mode=\'/opt/scripts/maintenance-mode.sh\'" >> /root/.bashrc + echo "Registering maintenance script as command." + echo "alias maintenance=\'/opt/scripts/maintenance.sh\'" >> /root/.bashrc + rm -f /opt/.firstrun echo "Done." echo ' ' fi diff --git a/amd64/scripts/maintenance-mode.sh b/amd64/scripts/maintenance.sh similarity index 58% rename from amd64/scripts/maintenance-mode.sh rename to amd64/scripts/maintenance.sh index b69ebcb..0ece4a0 100644 --- a/amd64/scripts/maintenance-mode.sh +++ b/amd64/scripts/maintenance.sh @@ -13,16 +13,17 @@ then fi elif [ "$1" == "on" ] then - echo 'This will stop ioBroker and enable maintenance mode for this container.' - read -p 'Continue? Type yes or no: ' A - if [ "$A" == "y" ] || [ "$A" == "yes" ] + echo 'You are going to stop ioBroker and activating maintenance mode for this container.' + read -p 'Do you want to continue [yes/no]? ' A + if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ] then - echo 'Enabling maintenance mode...' + echo 'Activating maintenance mode...' echo "maintenance" > /opt/iobroker/.docker_config/.healthcheck + sleep 1 echo 'Done.' - sleep 2 echo 'Stopping ioBroker...' pkill -u iobroker + sleep 1 echo 'Done.' exit 0 else @@ -30,12 +31,12 @@ then fi elif [ "$1" == "off" ] then - echo 'Depending of the restart policy of this container, this will force it to stop (and restart) immediately.' - echo 'Maintenance mode will be disabled after the restart.' - read -p 'Continue? Type yes or no: ' A - if [ "$A" == "y" ] || [ "$A" == "yes" ] + echo 'You are going to deactivate maintenance mode for this container.' + echo 'Depending of the restart policy of this container, this will stop/ restart your container immediately.' + read -p 'Do you want to continue [yes/no]? ' A + if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ] then - echo 'Disabling maintenance mode and forcing container to stop/ restart...' + echo 'Deactivating maintenance mode and forcing container to stop/ restart...' echo "maintenance" > /opt/iobroker/.docker_config/.healthcheck pkill -u root exit 0