自用发布脚本

网友投稿 1181 2022-08-23

自用发布脚本

自用发布脚本

包含tomcat、jar、rust

#!/bin/bashbak_date=`date +%Y%m%d`bak_dir=/data/bak/$bak_dateuser=weshopfunction deploy_script(){ #同步到生产服务器,排除log目录,本地没有的文件远程服务器也会删除 #方式1# for i in gdd-prod01 gdd-prod02# do # echo "同步目录到$i"# rsync -avg --delete $project_dir $i:/data/prod/service/ --exclude log# echo "同步目录完成,正在重启服务..."# expect </dev/null mv -f $project_name$bak_date.tar $bak_dir/ echo "备份完成,发布中.."}mkdir -p $bak_dircd /data/prod/service/echo "********************************* 请使用weshop用户执行此脚本 project_name: 1.gdd-wxcommon 2.advanced-statistics 3.advanced-product 4.advanced-coupon 5.advanced-job 6.advanced-order 7.advanced-report 8.advanced-shop 9.gdd-bill 10.gdd-cashier 11.gdd-common 12.gdd_message 13.gdd-xuser 14.order*********************************"read -p "后端发布专用,请选择要发布的项目序号,多个序号使用,号分隔" project_numbercase $project_number in 1) project_name=gdd-wxcommon project_dir=/data/prod/service/$project_name project_port=20090 #project_restart=sh tomcat20090/restart.sh #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh tomcat20090/restart.sh&&sleep 2 &&tail log/access/info" echo "重启服务完成,部署完成。" ;; 2) project_name=advanced-statistics project_dir=/data/prod/service/$project_name project_port=20120 #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh run.sh restart &&sleep 2 &&tail log/advanced_statistics.log" echo "重启服务完成,部署完成。" ;; 3) project_name=advanced-product project_port=20020 project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh run.sh $project_name &&sleep 2 &&tail log/$project_name.$project_date-0.log" echo "重启服务完成,部署完成。" ;; 4) project_name=advanced-coupon project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh run.sh $project_name &&sleep 2 &&tail log/$project_name.$project_date-0.log" echo "重启服务完成,部署完成。" ;; 5) project_name=advanced-job project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." for i in gdd-prod01 gdd-prod02 do ssh $user@$i "cd $project_dir &&nohup sh $project_name.sh stop &&nohup sh $project_name.sh start cfg/application-prod.yml&&sleep 2 &&tail log/$project_name.$project_date-0.log" echo "重启服务完成,$i部署完成。" sleep 3 done ;; 6) project_name=advanced-order project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh run.sh &&sleep 2 &&tail log/$project_name.$project_date-0.log" echo "重启服务完成,部署完成。" ;; 7) project_name=advanced-report project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." for i in gdd-prod01 gdd-prod02 do ssh $user@$i "cd $project_dir &&nohup sh $project_name.sh stop &&nohup sh $project_name.sh start cfg/application-prod.yml&&sleep 2 &&tail log/$project_name.$project_date-0.log" echo "重启服务完成,$i部署完成。" sleep 3 done echo "重启服务完成,部署完成。" ;; 8) project_name=advanced-shop project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh run.sh &&sleep 2 &&tail log/$project_name.$project_date-0.log" echo "重启服务完成,部署完成。" ;; 9) project_name=gdd-bill project_dir=/data/prod/service/$project_name project_date=`date +%Y%m%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh tomcat20110/restart.sh&&sleep 2 &&tail log/access/info.$project_date" echo "重启服务完成,部署完成。" ;; 10) project_name=gdd-cashier project_dir=/data/prod/service/$project_name project_date=`date +%Y%m%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh tomcat20060/restart.sh&&sleep 2 &&tail log/access/info.$project_date" echo "重启服务完成,部署完成。" ;; 11) project_name=gdd-common project_dir=/data/prod/service/$project_name project_date=`date +%Y%m%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh tomcat20080/restart.sh&&sleep 2 &&tail tomcat20080/logs/catalina.out" echo "重启服务完成,部署完成。" ;; 12) project_name=gdd_message project_dir=/data/prod/service/$project_name project_date=`date +%Y%m%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh tomcat20150/restart.sh&&sleep 2 &&tail tomcat20150/logs/catalina.out" echo "重启服务完成,部署完成。" ;; 13) project_name=gdd-xuser project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh restart_online.sh&&sleep 2 &&tail logs/$project_date.log" echo "重启服务完成,部署完成。" ;; 14) project_name=order project_dir=/data/prod/service/$project_name project_date=`date +%Y-%m-%d` #开始备份文件 backup_project #开始发布 deploy_script echo "同步目录完成,正在重启服务..." ansible ALL -m shell -a "cd $project_dir && nohup sh adv_order &" echo "重启服务完成,部署完成。" ;; *) echo "other" ;;esac

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:简析.NET Core 以及与 .NET Framework的关系
下一篇:找两个文件相同的内容和不同的内容
相关文章

 发表评论

暂时没有评论,来抢沙发吧~