#!/bin/bash
function function_system_health_check() {
local pid=$1
local port=$2
local dest=$3
local addr="${IP_ADDRESS}:${port}"
local node_id=${NODE_ID}
local protocol="http"
if ! kill -0 "${pid}" &>/dev/null; then
log_warning "process ${pid} is not exist"
return 1
fi
local i
local tls_opt=""
if [ "X${SSL_ENABLE}" = "Xtrue" ]; then
tls_opt="--cert ${CERTIFICATE_FILE_PATH} --key ${PRIVATE_KEY_PATH} --cacert ${VERIFY_FILE_PATH}"
protocol="https"
fi
for ((i = 1; i <= FS_HEALTH_CHECK_RETRY_TIMES; i++)); do
local ret_code=$(LD_LIBRARY_PATH="" timeout ${FS_HEALTH_CHECK_TIMEOUT} curl ${tls_opt} -s -m "${FS_HEALTH_CHECK_TIMEOUT}" -H "Node-ID:${NODE_ID}" -H "PID:${pid}" \
"${protocol}://${addr}/${dest}/healthy" -w %{http_code};echo $?)
if [ "x${ret_code:0:3}" = "x200" ]; then
return 0
fi
if ! kill -0 "${pid}" &>/dev/null; then
log_warning "process ${pid} is not exist"
return 1
fi
if [ $i -ge $FS_HEALTH_CHECK_RETRY_TIMES ]; then
log_warning "${addr} health check exceed max retry times. code ${ret_code}"
return 1
fi
sleep $FS_HEALTH_CHECK_RETRY_INTERVAL
done
return 1
}
function dashboard_health_check() {
local pid=$1
if ! kill -0 "${pid}" &>/dev/null; then
return 1
fi
return 0
}
function metaservice_health_check() {
local pid=$1
if ! kill -0 "${pid}" &>/dev/null; then
return 1
fi
return 0
}
function faas_frontend_health_check() {
local pid=$1
if ! kill -0 "${pid}" &>/dev/null; then
return 1
fi
return 0
}