构建新增镜像方式 #76

Merged
root merged 1 commits from xinwei into master 2024-09-13 10:55:34 +08:00

View File

@ -0,0 +1,93 @@
#!/bin/bash
cd /ludu
# 定义要检查的服务和 URL
declare -A services=(
["mysql"]="http://101.43.112.107:3306"
["mongo"]="http://101.43.112.107:27017"
#["redis"]="http://101.43.112.107:6379"
["nacos"]="http://101.43.112.107/nacos/#"
)
# 检查服务是否可达
check_services() {
for service in "${!services[@]}"; do
url="${services[$service]}"
if ! curl --silent --fail "$url"; then
echo "Error: $service is not available at $url."
return 1
fi
done
return 0
}
# 从命令行参数获取服务类型
SERVICE_TYPE=$1
# 检查服务类型是否提供
if [ -z "$SERVICE_TYPE" ]; then
echo "Usage: $0 <service_type>"
exit 1
fi
# 检查端口是否全部可达
if check_services; then
# 根据服务类型启动不同的服务
case $SERVICE_TYPE in
"gateway")
docker-compose stop yudao-gateway
docker-compose rm yudao-gateway
docker-compose pull yudao-gateway
docker-compose up -d yudao-gateway
;;
"system")
docker-compose stop yudao-system
docker-compose rm yudao-system
docker-compose pull yudao-system
docker-compose up -d yudao-system
;;
"job")
docker-compose stop ludu-job-admin
docker-compose rm ludu-job-admin
docker-compose pull ludu-job-admin
docker-compose up -d ludu-job-admin
;;
"infra")
docker-compose stop yudao-infra
docker-compose rm yudao-infra
docker-compose pull yudao-infra
docker-compose up -d yudao-infra
;;
"datacenter")
docker-compose stop ludu-datacenter
docker-compose rm ludu-datacenter
docker-compose pull ludu-datacenter
docker-compose up -d ludu-datacenter
;;
"parking")
docker-compose stop ludu-parking
docker-compose rm ludu-parking
docker-compose pull ludu-parking
docker-compose up -d ludu-parking
;;
"ticketing")
docker-compose stop ludu-ticketing
docker-compose rm ludu-ticketing
docker-compose pull ludu-ticketing
docker-compose up -d ludu-ticketing
;;
"all")
docker-compose down
docker-compose pull
docker-compose up -d
;;
*)
echo "Invalid service type."
exit 1
;;
esac
echo "Started service: $SERVICE_TYPE"
else
echo "One or more required services are not available. Please check the dependencies."
fi