From c19158cd76e273b672db6fbf87ee54c8295acbfe Mon Sep 17 00:00:00 2001 From: Pratik <68642400+pratikbalar@users.noreply.github.com> Date: Mon, 21 Jun 2021 18:19:46 +0530 Subject: [PATCH] refactor: remove exports, add bash flags healthchecks Add bash flags and removed - errexit - better for fast fail of healthchecks - allexport - export vars by default - nolog - not to add in history (optional) --- build/common/worker/healthcheck.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/build/common/worker/healthcheck.sh b/build/common/worker/healthcheck.sh index 6fac34b7..5811d740 100755 --- a/build/common/worker/healthcheck.sh +++ b/build/common/worker/healthcheck.sh @@ -1,28 +1,29 @@ #!/bin/bash +set -o errexit -o allexport -o nolog -export COMMON_SITE_CONFIG_JSON='/home/frappe/frappe-bench/sites/common_site_config.json' +COMMON_SITE_CONFIG_JSON='/home/frappe/frappe-bench/sites/common_site_config.json' # Set DB Host and port -export DB_HOST=`cat $COMMON_SITE_CONFIG_JSON | awk '/db_host/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n'` -export DB_PORT=`cat $COMMON_SITE_CONFIG_JSON | awk '/db_port/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n'` +DB_HOST=`cat $COMMON_SITE_CONFIG_JSON | awk '/db_host/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n'` +DB_PORT=`cat $COMMON_SITE_CONFIG_JSON | awk '/db_port/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n'` if [[ -z "$DB_PORT" ]]; then - export DB_PORT=3306 + DB_PORT=3306 fi # Set REDIS host:port -export REDIS_CACHE=`cat $COMMON_SITE_CONFIG_JSON | awk '/redis_cache/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'` +REDIS_CACHE=`cat $COMMON_SITE_CONFIG_JSON | awk '/redis_cache/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'` if [[ "$REDIS_CACHE" == *"/"* ]]; then - export REDIS_CACHE=`echo $REDIS_CACHE | cut -f1 -d"/"` + REDIS_CACHE=`echo $REDIS_CACHE | cut -f1 -d"/"` fi -export REDIS_QUEUE=`cat $COMMON_SITE_CONFIG_JSON | awk '/redis_queue/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'` +REDIS_QUEUE=`cat $COMMON_SITE_CONFIG_JSON | awk '/redis_queue/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'` if [[ "$REDIS_QUEUE" == *"/"* ]]; then - export REDIS_QUEUE=`echo $REDIS_QUEUE | cut -f1 -d"/"` + REDIS_QUEUE=`echo $REDIS_QUEUE | cut -f1 -d"/"` fi -export REDIS_SOCKETIO=`cat $COMMON_SITE_CONFIG_JSON | awk '/redis_socketio/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'` +REDIS_SOCKETIO=`cat $COMMON_SITE_CONFIG_JSON | awk '/redis_socketio/ { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'` if [[ "$REDIS_SOCKETIO" == *"/"* ]]; then - export REDIS_SOCKETIO=`echo $REDIS_SOCKETIO | cut -f1 -d"/"` + REDIS_SOCKETIO=`echo $REDIS_SOCKETIO | cut -f1 -d"/"` fi echo "Check $DB_HOST:$DB_PORT"