From cb4c6b4c1a4da6ce490d5a8282a33da2a44708ad Mon Sep 17 00:00:00 2001 From: Alec Turner Date: Wed, 3 Apr 2024 16:28:04 -0700 Subject: [PATCH] remove unnecessary check for setup process autoheal was copied from kenya-emr and was still checking for a setup.pid file and process. This won't do any harm but also does not add value. --- .../streamline/streamline-emr/autoheal | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/root/var/signalytic/clientapps/streamline/streamline-emr/autoheal b/root/var/signalytic/clientapps/streamline/streamline-emr/autoheal index 7cd9538f..68a541b1 100755 --- a/root/var/signalytic/clientapps/streamline/streamline-emr/autoheal +++ b/root/var/signalytic/clientapps/streamline/streamline-emr/autoheal @@ -18,25 +18,20 @@ trap exit INT # run at fixed interval, checking for and restarting any service marked as 'unhealthy' pushd $LOCATION > /dev/null while [ 1 ]; do + # get current state (running or not) and status (healthy, unhealthy, etc) + app_state=$(docker compose ps --format '{{.State}}' streamline-emr) + app_status=$(docker compose ps --format '{{.Status}}' streamline-emr) - # if setup is not running, make sure containers are active and running - if ! kill -0 $(cat ${LOCATION}/setup.pid 2> /dev/null) 2> /dev/null; then - - # get current state (running or not) and status (healthy, unhealthy, etc) - app_state=$(docker compose ps --format '{{.State}}' streamline-emr) - app_status=$(docker compose ps --format '{{.Status}}' streamline-emr) - - # check if app is running and healhty - if [ "${app_state}" = "running" ]; then - if [[ "${app_status}" = *\(unhealthy\) ]]; then - echo "Unhealthy service detected. Restarting 'streamline-emr'" - docker compose restart streamline-emr - fi - # app should be running - restart - else - echo "Container not running. Starting 'streamline-emr'" - docker compose up -d streamline-emr + # check if app is running and healhty + if [ "${app_state}" = "running" ]; then + if [[ "${app_status}" = *\(unhealthy\) ]]; then + echo "Unhealthy service detected. Restarting 'streamline-emr'" + docker compose restart streamline-emr fi + # app should be running - restart + else + echo "Container not running. Starting 'streamline-emr'" + docker compose up -d streamline-emr fi # wait a little while before checking again