2020-09-15 23:18:28 +05:30
|
|
|
#!/bin/bash
|
2021-06-21 22:32:37 +05:30
|
|
|
set -ea
|
2020-09-15 23:18:28 +05:30
|
|
|
|
2021-06-21 23:02:00 +05:30
|
|
|
function getUrl() {
|
2021-06-23 09:13:24 +05:30
|
|
|
grep "$2" "$1" | awk -v word="$2" '$word { gsub(/[",]/,"",$2); print $2}' | tr -d '\n'
|
2021-06-21 22:56:05 +05:30
|
|
|
}
|
|
|
|
|
2021-06-21 18:19:46 +05:30
|
|
|
COMMON_SITE_CONFIG_JSON='/home/frappe/frappe-bench/sites/common_site_config.json'
|
2020-09-16 14:20:10 +05:30
|
|
|
|
2020-09-15 23:18:28 +05:30
|
|
|
# Set DB Host and port
|
2021-06-23 09:13:24 +05:30
|
|
|
DB_HOST=$(getUrl "${COMMON_SITE_CONFIG_JSON}" "db_host")
|
|
|
|
DB_PORT=$(getUrl "${COMMON_SITE_CONFIG_JSON}" "db_port")
|
|
|
|
if [[ -z "${DB_PORT}" ]]; then
|
2021-06-21 22:56:05 +05:30
|
|
|
DB_PORT=3306
|
2020-09-15 23:18:28 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
# Set REDIS host:port
|
2021-06-23 09:13:24 +05:30
|
|
|
REDIS_CACHE=$(getUrl "${COMMON_SITE_CONFIG_JSON}" "redis_cache" | sed 's|redis://||g')
|
|
|
|
if [[ "${REDIS_CACHE}" == *"/"* ]]; then
|
2021-11-09 13:05:29 +03:00
|
|
|
REDIS_CACHE=$(echo "${REDIS_CACHE}" | cut -f1 -d"/")
|
2020-10-06 14:43:36 +05:30
|
|
|
fi
|
|
|
|
|
2021-06-23 09:13:24 +05:30
|
|
|
REDIS_QUEUE=$(getUrl "${COMMON_SITE_CONFIG_JSON}" "redis_queue" | sed 's|redis://||g')
|
|
|
|
if [[ "${REDIS_QUEUE}" == *"/"* ]]; then
|
2021-11-09 13:05:29 +03:00
|
|
|
REDIS_QUEUE=$(echo "${REDIS_QUEUE}" | cut -f1 -d"/")
|
2020-10-06 14:43:36 +05:30
|
|
|
fi
|
|
|
|
|
2021-06-23 09:13:24 +05:30
|
|
|
REDIS_SOCKETIO=$(getUrl "${COMMON_SITE_CONFIG_JSON}" "redis_socketio" | sed 's|redis://||g')
|
|
|
|
if [[ "${REDIS_SOCKETIO}" == *"/"* ]]; then
|
2021-11-09 13:05:29 +03:00
|
|
|
REDIS_SOCKETIO=$(echo "${REDIS_SOCKETIO}" | cut -f1 -d"/")
|
2020-10-06 14:43:36 +05:30
|
|
|
fi
|
2020-09-15 23:18:28 +05:30
|
|
|
|
2021-06-23 09:13:24 +05:30
|
|
|
echo "Check ${DB_HOST}:${DB_PORT}"
|
|
|
|
wait-for-it "${DB_HOST}:${DB_PORT}" -t 1
|
|
|
|
echo "Check ${REDIS_CACHE}"
|
|
|
|
wait-for-it "${REDIS_CACHE}" -t 1
|
|
|
|
echo "Check ${REDIS_QUEUE}"
|
|
|
|
wait-for-it "${REDIS_QUEUE}" -t 1
|
|
|
|
echo "Check ${REDIS_SOCKETIO}"
|
|
|
|
wait-for-it "${REDIS_SOCKETIO}" -t 1
|
2020-09-15 23:18:28 +05:30
|
|
|
|
2021-06-22 15:44:25 +05:30
|
|
|
if [[ "$1" = "-p" || "$1" = "--ping-service" ]]; then
|
2021-06-21 22:56:05 +05:30
|
|
|
echo "Check $2"
|
|
|
|
wait-for-it "$2" -t 1
|
2020-09-15 23:18:28 +05:30
|
|
|
fi
|