2020-09-15 17:48:28 +00:00
|
|
|
#!/bin/bash
|
2021-06-21 17:02:37 +00:00
|
|
|
set -ea
|
2020-09-15 17:48:28 +00:00
|
|
|
|
2021-06-21 17:26:05 +00:00
|
|
|
function getRedisUrl() {
|
|
|
|
cat ${1} | grep $2 | awk -v word=$2 '$word { gsub(/[",]/,"",$2); print $2}' | tr -d '\n' | sed 's|redis://||g'
|
|
|
|
}
|
|
|
|
|
2021-06-21 12:49:46 +00:00
|
|
|
COMMON_SITE_CONFIG_JSON='/home/frappe/frappe-bench/sites/common_site_config.json'
|
2020-09-16 08:50:10 +00:00
|
|
|
|
2020-09-15 17:48:28 +00:00
|
|
|
# Set DB Host and port
|
2021-06-21 17:26:05 +00:00
|
|
|
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')
|
2020-09-15 17:48:28 +00:00
|
|
|
if [[ -z "$DB_PORT" ]]; then
|
2021-06-21 17:26:05 +00:00
|
|
|
DB_PORT=3306
|
2020-09-15 17:48:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set REDIS host:port
|
2021-06-21 17:26:05 +00:00
|
|
|
REDIS_CACHE=$(getRedisUrl "$COMMON_SITE_CONFIG_JSON" "redis_cache")
|
2020-10-06 09:13:36 +00:00
|
|
|
if [[ "$REDIS_CACHE" == *"/"* ]]; then
|
2021-06-21 17:26:05 +00:00
|
|
|
REDIS_CACHE=$(echo $REDIS_CACHE | cut -f1 -d"/")
|
2020-10-06 09:13:36 +00:00
|
|
|
fi
|
|
|
|
|
2021-06-21 17:26:05 +00:00
|
|
|
REDIS_QUEUE=$(getRedisUrl "$COMMON_SITE_CONFIG_JSON" "redis_queue")
|
2020-10-06 09:13:36 +00:00
|
|
|
if [[ "$REDIS_QUEUE" == *"/"* ]]; then
|
2021-06-21 17:26:05 +00:00
|
|
|
REDIS_QUEUE=$(echo $REDIS_QUEUE | cut -f1 -d"/")
|
2020-10-06 09:13:36 +00:00
|
|
|
fi
|
|
|
|
|
2021-06-21 17:26:05 +00:00
|
|
|
REDIS_SOCKETIO=$(getRedisUrl "$COMMON_SITE_CONFIG_JSON" "redis_socketio")
|
2020-10-06 09:13:36 +00:00
|
|
|
if [[ "$REDIS_SOCKETIO" == *"/"* ]]; then
|
2021-06-21 17:26:05 +00:00
|
|
|
REDIS_SOCKETIO=$(echo $REDIS_SOCKETIO | cut -f1 -d"/")
|
2020-10-06 09:13:36 +00:00
|
|
|
fi
|
2020-09-15 17:48:28 +00:00
|
|
|
|
|
|
|
echo "Check $DB_HOST:$DB_PORT"
|
2021-06-21 17:26:05 +00:00
|
|
|
wait-for-it "$DB_HOST:$DB_PORT" -t 1
|
2020-09-15 17:48:28 +00:00
|
|
|
echo "Check $REDIS_CACHE"
|
2021-06-21 17:26:05 +00:00
|
|
|
wait-for-it "$REDIS_CACHE" -t 1
|
2020-09-15 17:48:28 +00:00
|
|
|
echo "Check $REDIS_QUEUE"
|
2021-06-21 17:26:05 +00:00
|
|
|
wait-for-it "$REDIS_QUEUE" -t 1
|
2020-09-15 17:48:28 +00:00
|
|
|
echo "Check $REDIS_SOCKETIO"
|
2021-06-21 17:26:05 +00:00
|
|
|
wait-for-it "$REDIS_SOCKETIO" -t 1
|
2020-09-15 17:48:28 +00:00
|
|
|
|
|
|
|
if [[ "$1" = "-p" ]] || [[ "$1" = "--ping-service" ]]; then
|
2021-06-21 17:26:05 +00:00
|
|
|
echo "Check $2"
|
|
|
|
wait-for-it "$2" -t 1
|
2020-09-15 17:48:28 +00:00
|
|
|
fi
|