You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
#! /bin/sh
|
|
group_id=$1
|
|
image_name=$1/$2
|
|
module_name=$2
|
|
image_port=$3
|
|
registry_url=$4
|
|
eureka_url=$5
|
|
image_tag=latest
|
|
host_port=$image_port
|
|
|
|
# 截取到服务名称,如fastwave/fastwave-service-admin,载取后变为fastwave-service-admin
|
|
service_withprefix_name=$1
|
|
service_name_array=(${service_withprefix_name//\// })
|
|
service_name=${service_name_array[1]}
|
|
|
|
#向eureka发送指令,让服务停止,即不再接收新的请求,这样终止服务将更柔性化
|
|
nohup sh /data/jenkins_shell/disable_service.sh ${service_name} ${image_port} ${eureka_url}
|
|
|
|
# 休眠一段时间,建议设置超过90秒以上,演示可以设置为30秒
|
|
# sleep 2m
|
|
sleep 30s
|
|
|
|
# 备份镜像到镜像仓库
|
|
echo "备份镜像到镜像仓库"
|
|
#/data/jenkins_shell/backup_image.sh $image_name $image_tag $registry_url
|
|
|
|
#两个可以不用停止WEB服务就可以清空nohup.out的命令。
|
|
#第一种:cp /dev/null nohup.out
|
|
#第二种:cat /dev/null > nohup.out
|
|
cp /dev/null nohup.out
|
|
#sleep 2m
|
|
#停掉容器、删除容器、删除镜像
|
|
echo "停掉容器、删除容器、删除镜像 /data/jenkins_shell/delete_image.sh $image_name $image_tag"
|
|
/data/jenkins_shell/delete_image.sh $image_name $image_tag
|
|
#pull镜像
|
|
#echo "docker pull $image_name:$image_tag"
|
|
docker pull localhost:5001/${image_name}
|
|
|
|
# 将运行的镜像,重新修改tag命名为server
|
|
docker tag localhost:5001/${image_name}:${image_tag} ${image_name}:${image_tag}
|
|
#将本地刚重命名的镜像删除
|
|
echo "docker rmi localhost:5001/${image_name}:${image_tag}"
|
|
docker rmi localhost:5001/${image_name}:${image_tag}
|
|
|
|
#运行镜像
|
|
echo "运行镜像 docker run --restart=always --name ${module_name} -d -t ${image_name}:$image_tag"
|
|
docker run --restart=always --name ${module_name} -d --network=host -t ${image_name}:$image_tag
|
|
|