mirror of
https://github.com/frappe/frappe_docker.git
synced 2024-11-09 14:50:58 +00:00
Merge pull request #490 from pratikbalar/patch-1
refactor: remove exports, add bash flags healthchecks
This commit is contained in:
commit
b8c290c0e8
@ -1,40 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -ea
|
||||
|
||||
export COMMON_SITE_CONFIG_JSON='/home/frappe/frappe-bench/sites/common_site_config.json'
|
||||
function getUrl() {
|
||||
cat ${1} | grep $2 | awk -v word=$2 '$word { gsub(/[",]/,"",$2); print $2}' | tr -d '\n'
|
||||
}
|
||||
|
||||
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=$(getUrl "$COMMON_SITE_CONFIG_JSON" "db_host")
|
||||
DB_PORT=$(getUrl "$COMMON_SITE_CONFIG_JSON" "db_port")
|
||||
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=$(getUrl "$COMMON_SITE_CONFIG_JSON" "redis_cache" | 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=$(getUrl "$COMMON_SITE_CONFIG_JSON" "redis_queue" | 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=$(getUrl "$COMMON_SITE_CONFIG_JSON" "redis_socketio" | 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"
|
||||
wait-for-it $DB_HOST:$DB_PORT -t 1
|
||||
wait-for-it "$DB_HOST:$DB_PORT" -t 1
|
||||
echo "Check $REDIS_CACHE"
|
||||
wait-for-it $REDIS_CACHE -t 1
|
||||
wait-for-it "$REDIS_CACHE" -t 1
|
||||
echo "Check $REDIS_QUEUE"
|
||||
wait-for-it $REDIS_QUEUE -t 1
|
||||
wait-for-it "$REDIS_QUEUE" -t 1
|
||||
echo "Check $REDIS_SOCKETIO"
|
||||
wait-for-it $REDIS_SOCKETIO -t 1
|
||||
wait-for-it "$REDIS_SOCKETIO" -t 1
|
||||
|
||||
if [[ "$1" = "-p" ]] || [[ "$1" = "--ping-service" ]]; then
|
||||
echo "Check $2"
|
||||
wait-for-it $2 -t 1
|
||||
echo "Check $2"
|
||||
wait-for-it "$2" -t 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user