Merge pull request #6569 from dataease/pr@dev-v2_healthcheck

refactor: 修改healthcheck方法
This commit is contained in:
fit2cloudrd 2023-11-07 17:24:02 +08:00 committed by GitHub
commit 9fa81f273e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 28 deletions

View File

@ -66,21 +66,32 @@ function _init_apisix() {
function _healthcheck() { function _healthcheck() {
echo 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 do
sleep 3 sleep 1
http_code=$(curl -sILw "%{http_code}\n" http://localhost:${DE_PORT} -o /dev/null) read status healthy<<<$(docker inspect $container_name --format '{{.State.Status}} {{.State.Health.Status}}')
if [[ $http_code == 000 ]];then if [[ "$healthy" == "starting" ]];then
echo "DataEase 服务状态 : 正在启动" printf "\rDataEase 服务状态 : 正在启动 ... %3ds" $b
elif [[ $http_code == 200 ]];then elif [[ "$status" == "running" ]] && [[ "$healthy" == "healthy" ]];then
echo "DataEase 服务状态 : 正常运行" printf "\rDataEase 服务状态 : 正常运行 "
break; echo
return;
else else
echo
echo -e "DataEase 服务状态 : \033[31m无法访问\033[0m" echo -e "DataEase 服务状态 : \033[31m无法访问\033[0m"
exit 1 exit 1
fi fi
done done
echo echo
echo "【警告】服务在等待时间内未完全启动!请稍后使用 dectl status 检查服务运行状况。"
echo
} }
function _get_current_version() { function _get_current_version() {
de_current_version=$(grep "^ image:.*dataease:" ${DE_RUNNING_BASE}/docker-compose.yml | awk -F'dataease:' '{print $2}') 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 start | tee -a ${CURRENT_DIR}/install.log
dectl status 2>&1 | 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" 2>&1 | tee -a ${CURRENT_DIR}/install.log
echo -e "系统登录信息如下:\n 用户名: admin\n 初始密码: dataease" 2>&1 | tee -a ${CURRENT_DIR}/install.log