shell编译部署java项目自动化脚本

前端之家收集整理的这篇文章主要介绍了shell编译部署java项目自动化脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
green='\e[0;32m' # 绿色 
NC='\e[0m' # 没有颜色
#TUES_WEBSERVER_PID=$(ps x|grep /home/admin/tues-webserver/tues-webserver/target/tues-webserver-0.0.1-SNAPSHOT.jar |awk '{print $1}')
TUES_WEBSERVER_PID=$(cat /home/admin/sh/tues-webserver.pid)
if [ -n "$TUES_WEBSERVER_PID" ]
then
    echo 'kill '$TUES_WEBSERVER_PID
    kill $TUES_WEBSERVER_PID
fi
echo 'start update tues-weberser project'
cd /home/admin/tues-webserver
git pull origin master
echo 'start build tues-webserver project'
cd /home/admin/tues-webserver/tues-webserver
mvn install
cd /home/admin/tues-webserver/tues-webserver/target
echo 'start deploy tues-webserver project'
nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8002,suspend=n -jar /home/admin/tues-webserver/tues-webserver/target/tues-webserver-0.0.1-SNAPSHOT.jar --spring.profiles.active=online > /home/admin/logs/start.log 2>&1 &
echo $! > /home/admin/sh/tues-webserver.pid

START_TIME=`date +%s`
while [[ -z `netstat -ln|grep 9002` ]]
do
    TIME_TOTAL=$[`date +%s`-START_TIME]
    printf "\r" $b $i
    echo -n "[tues-webserver] the server is starting :$TIME_TOTAL S "
    sleep 1
done
echo -e "\n${green}[tues-webserver] the tuew-webserver start finihed${NC}"



SVN版本
GREEN='\e[0;32m' # 绿色
NC='\e[0m' # 没有颜色

echo "${GREEN}start update cos project${NC}"
cd /usr/local/java/workspace/ycl-platform
svn update
echo -e "${GREEN}start build cos project${NC}"
cd /usr/local/java/workspace/ycl-platform
mvn package -Dmaven.test.skip=true
echo -e "${GREEN}stop cos project${NC}"
PID=$(cat /usr/local/java/sh/cos.pid)
echo "kill PID=$PID"
kill -9 $PID
cd /usr/local/java/workspace/ycl-platform/ycl-web/ycl-cos/target
echo -e "${GREEN} copy cos project ${NC}"
cp -rf ycl-cos /usr/local/java/tomcat/cos/webapps
cd /usr/local/java/tomcat/cos/bin
sh catalina.sh start
START_TIME=`date +%s`
while [[ -z `curl –connect-timeout 1 -m 1 http://localhost:8115/ -s` ]]
do
        TIME_TOTAL=$[`date +%s`-START_TIME]
        printf "\r" $b $i
        echo -en "${GREEN}[cos] the server is starting :$TIME_TOTAL S  ${NC}"

done
echo $(ps -ef|grep cos|awk '{print $2}') > /usr/local/java/sh/cos.pid
PID_STR=$(cat /usr/local/java/sh/cos.pid)
PID=$(echo ${PID_STR%% *})
echo $PID > /usr/local/java/sh/cos.pid
echo -e "\n${GREEN}[cos] the server start finihed${NC}"
原文链接:https://www.f2er.com/bash/391864.html

猜你在找的Bash相关文章