templates.service.sh.ftl Maven / Gradle / Ivy
#!/bin/bash
Version=${project.version}
Active=${project.active}
jar_name=${project.artifactId}-${project.version}.jar
echo "------------------------------------停掉删除所有镜像---------------------------------"
echo ""
pid=$(ps -ef | grep $jar_name | grep -v grep | awk '{print $2}')
if [ -z $pid ]; then # -z 是判断是否为空
echo "${r'${jar_name}'}未运行!"
else
echo "准备关闭进程$pid"
kill -9 $pid
sleep 0.5
echo "${r'${jar_name}'}已关闭!"
fi
echo ""
docker stop ${project.artifactId}-${project.version}
docker rm ${project.artifactId}-${project.version}
docker rmi ${cloudImage.registry}/${cloudImage.namespace}/${project.artifactId}:${project.version}
echo "------------------------------------停掉删除所有镜像(完成)----------------------------"
sudo docker login --username=${cloudImage.username} --password=${cloudImage.password} ${cloudImage.registry}
sudo docker pull ${cloudImage.registry}/${cloudImage.namespace}/${project.artifactId}:${project.version}
echo "------------------------下载镜像(完成)---------------------------"
docker run -d <#list project.port as p >-p ${p}:${p} #list> --network=host --name=${project.artifactId}-${project.version} -e NACOS_ACTIVE=$Active -e ACTIVE=$Active ${project.dockerParameter} -e TZ=Asia/Shanghai -e JAVA_OPTS="${project.jvmParameter}" ${cloudImage.registry}/${cloudImage.namespace}/${project.artifactId}:${project.version}
echo "-----------------------------------启动完成-----------------------------------------"