shell脚本自动化部署服务
生活随笔
收集整理的這篇文章主要介紹了
shell脚本自动化部署服务
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
shell腳本自動化部署
!/bin/bash#export PATH=$PATH:/export/maven/binrun_flag_dir="/data0/shell/deploy_workspace/Test" if [ ! -d "$run_flag_dir" ]; thenmkdir -p "$run_flag_dir" fi#判斷是否正在部署,如果是則退出 if [ -f "$run_flag_dir/.run" ]; thenecho "程序部署中,請勿重復部署!"exit 1 fi#創建.run文件,標識腳本正在部署 touch "$run_flag_dir/.run" #捕獲Ctrl+C,刪除.run文件,避免狀態不一致 trap "rm -r $run_flag_dir/.run; exit 1" 2export JAVA_HOME=/data0/usr/jdk1.8.0_60//bin/rm -rf ./deploy_workspace/Testecho "##############################################################" echo "開始git下載代碼。。。" echo "##############################################################"cd /data0/shell/deploy_workspace if [ ! -d "Test" ]; thengit clone -b dev git@git.jd.com:AIBDP-Mobile/Test.gitcd Testgit pull elsecd Testgit pull fiecho "##############################################################" echo "開始編譯代碼。。。" echo "##############################################################" cd /data0/shell/deploy_workspace/Test/ #cp -rf face-web/src/main/config/test/* ai-web/src/main/resources/ #/bin/rm -rf mobile-web/src/main/config/test/jss.properties cp -rf web/src/main/config/test/* web/src/main/resources/ mvn clean package -U -DskipTests -Dmaven.repo.local=/data0/repository #mvn clean package -DskipTestsif [ $? != 0 ]; thenecho "##############################################################"echo -e 'mvn打包出錯了,直接退出部署程序。。。';echo "##############################################################"/bin/rm -rf $run_flag_dir/.run;exit 1 fiecho "##############################################################" echo "開始停止tomcat。。。" echo "##############################################################" sh /data0/usr/apache-tomcat-8.5.24/bin/shutdown.sh sleep 3 ps -ef| grep "apache-tomcat-8.5.24" | grep -v grep | awk '{print $2}' | xargs kill -9 echo "====tomcat服務已停止成功。。。" echo "##############################################################"echo "##############################################################" echo -e "開始部署程序。。。" echo "##############################################################" cd /data0/shell/deploy_workspace/Test/ /bin/rm -rf /data0/usr/apache-tomcat-8.5.24/webapps/ROOT* unzip -q mobile-web/target/ROOT.war -d "/data0/usr/apache-tomcat-8.5.24/webapps/ROOT"echo "##############################################################" echo -e "開始啟動tomcat。。。" echo "##############################################################" export CATALINA_OPTS="-Xms1024M -Xmx1024M -server -XX:PermSize=256M" nohup sh /data0/usr/apache-tomcat-8.5.24/bin/startup.sh &#刪除.run文件,部署完畢 /bin/rm -rf $run_flag_dir/.run;echo "##############################################################" echo -e "開始打印日志。。。" echo "##############################################################"tail -f "/data0/usr/apache-tomcat-8.5.24/logs/catalina.out" View Code?
轉載于:https://www.cnblogs.com/zgzf/p/10525146.html
總結
以上是生活随笔為你收集整理的shell脚本自动化部署服务的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nginx配置upstream实现负载均
- 下一篇: 微信小程序实现图片是上传、预览功能