refactor: 修改healthcheck方法

This commit is contained in:
xuwei-fit2cloud 2023-11-07 17:23:07 +08:00
parent c08a334d5a
commit 6cf59b443e
2 changed files with 20 additions and 28 deletions

View File

@ -66,21 +66,32 @@ function _init_apisix() {
function _healthcheck() {
echo
for b in {1..30}
container_name=$(grep "container_name" $DE_RUNNING_BASE/docker-compose.yml | awk -F': ' '{print $2}')
sleep 1
if [ -z $(docker ps --filter "name=$container_name" -q) ];then
echo "未找到容器 $container_name请检查配置文件。"
exit 1
fi
for b in {1..90}
do
sleep 3
http_code=$(curl -sILw "%{http_code}\n" http://localhost:${DE_PORT} -o /dev/null)
if [[ $http_code == 000 ]];then
echo "DataEase 服务状态 : 正在启动"
elif [[ $http_code == 200 ]];then
echo "DataEase 服务状态 : 正常运行"
break;
sleep 1
read status healthy<<<$(docker inspect $container_name --format '{{.State.Status}} {{.State.Health.Status}}')
if [[ "$healthy" == "starting" ]];then
printf "\rDataEase 服务状态 : 正在启动 ... %3ds" $b
elif [[ "$status" == "running" ]] && [[ "$healthy" == "healthy" ]];then
printf "\rDataEase 服务状态 : 正常运行 "
echo
return;
else
echo
echo -e "DataEase 服务状态 : \033[31m无法访问\033[0m"
exit 1
fi
done
echo
echo "【警告】服务在等待时间内未完全启动!请稍后使用 dectl status 检查服务运行状况。"
echo
}
function _get_current_version() {
de_current_version=$(grep "^ image:.*dataease:" ${DE_RUNNING_BASE}/docker-compose.yml | awk -F'dataease:' '{print $2}')

View File

@ -238,24 +238,5 @@ log "启动服务"
dectl start | tee -a ${CURRENT_DIR}/install.log
dectl status 2>&1 | tee -a ${CURRENT_DIR}/install.log
for b in {1..30}
do
sleep 3
http_code=$(curl -sILw "%{http_code}\n" http://localhost:${DE_PORT} -o /dev/null)
if [[ $http_code == 000 ]];then
log "服务启动中,请稍候 ..."
elif [[ $http_code == 200 ]];then
log "服务启动成功!"
break;
else
log "服务启动出错!"
exit 1
fi
done
if [[ $http_code != 200 ]];then
log "【警告】服务在等待时间内未完全启动!请稍后使用 dectl status 检查服务运行状况。"
fi
echo -e "======================= 安装完成 =======================\n" 2>&1 | tee -a ${CURRENT_DIR}/install.log
echo -e "系统登录信息如下:\n 用户名: admin\n 初始密码: dataease" 2>&1 | tee -a ${CURRENT_DIR}/install.log