首页 > 代码库 > tomcat程序全量更新脚本
tomcat程序全量更新脚本
#!/bin/bash #定义上线操作步骤 IP=`ifconfig | grep "inet addr" |grep 139|awk ‘{print $2}‘|awk -F":" ‘{print $2}‘` DATE=`date +%F` S_DIR="/home/zwjfadmin001" LC_PID=`ps aux |grep tomcat_lcApp |grep -v grep |awk ‘{print $2}‘` DK_PID=`ps aux |grep tomcat_dkApp |grep -v grep |awk ‘{print $2}‘` DU_PID=`ps aux |grep tomcat_dubbo |grep -v grep |awk ‘{print $2}‘` LCAD_PID=`ps aux |grep tomcat_lcAdmin |grep -v grep |awk ‘{print $2}‘` TIM_PID=`ps aux |grep tomcat_timer |grep -v grep |awk ‘{print $2}‘` echo $DATE #定义理财全量发布 function full_lc { echo "======================关闭理财应用=====================" cd /opt/ ./tomcat_lcApp/bin/catalina.sh stop sleep 3 kill -9 ${LC_PID} if [ "${LC_PID}" == "" ]; then echo "tomcat is stopd" else echo "tomcat is not stopd Please Check!" exit 0 fi cd tomcat_lcApp/onlineapp/ rm -rf lcApp/* echo "删除缓存文件" rm -rf /opt/tomcat_lcApp/temp/* /opt/tomcat_lcApp/work/Catalina/* echo "开始更新文件" unzip ${S_DIR}/lcApp.war -d /opt/tomcat_lcApp/onlineapp/lcApp echo "================更新完成,开始启动服务==================" cd /opt/ ./tomcat_lcApp/bin/catalina.sh start if [ "$?" == "0" ]; then echo "启动成功,请检查启动日志" tail -f /opt/tomcat_lcApp/logs/catalina.out else echo "启动失败,请检查服务" exit 0 fi } #定义贷款全量发布 function full_dk { echo "======================关闭贷款应用=====================" cd /opt/ ./tomcat_dkApp/bin/catalina.sh stop sleep 3 kill -9 ${DK_PID} if [ "${DK_PID}" == "" ]; then echo "tomcat is stopd" else echo "tomcat is not stopd Please Check!" exit 0 fi cd tomcat_dkApp/onlineapp/ rm -rf dkApp/* echo "删除缓存文件" rm -rf /opt/tomcat_dkApp/temp/* /opt/tomcat_dkApp/work/Catalina/* echo "开始更新文件" unzip ${S_DIR}/dkApp.war -d /opt/tomcat_dkApp/onlineapp/dkApp echo "================更新完成,开始启动服务==================" cd /opt/ ./tomcat_dkApp/bin/catalina.sh start if [ "$?" == "0" ]; then echo "启动成功,请检查启动日志" tail -f /opt/tomcat_dkApp/logs/catalina.out else echo "启动失败,请检查服务" exit 0 fi } #定义dubbo全量更新 function full_dubbo { echo "======================关闭DUBBO应用=====================" cd /opt/ ./tomcat_dubbo/bin/catalina.sh stop sleep 3 kill -9 ${DU_PID} if [ "${DU_PID}" == "" ]; then echo "tomcat is stopd" else echo "tomcat is not stopd Please Check!" exit 0 fi cd tomcat_dubbo/onlineapp/ rm -rf dubbo1/* echo "删除缓存文件" rm -rf /opt/tomcat_dubbo/temp/* /opt/tomcat_dubbo/work/Catalina/* echo "开始更新文件" unzip ${S_DIR}/dubboMainServer.war -d /opt/tomcat_dubbo/onlineapp/dubbo1 echo "================更新完成,开始启动服务==================" cd /opt/ ./tomcat_dubbo/bin/catalina.sh start if [ "$?" == "0" ]; then echo "启动成功,请检查启动日志" tail -f /opt/tomcat_dubbo/logs/catalina.out else echo "启动失败,请检查服务" exit 0 fi } function full_lcadmin { echo "======================关闭理财后台应用=====================" cd /opt/ ./tomcat_lcAdmin/bin/catalina.sh stop sleep 3 kill -9 ${LCAD_PID} if [ "${LCAD_PID}" == "" ]; then echo "tomcat is stopd" else echo "tomcat is not stopd Please Check!" exit 0 fi cd tomcat_lcAdmin/onlineapp/ rm -rf lcAdmin/* echo "删除缓存文件" rm -rf /opt/tomcat_lcAdmin/temp/* /opt/tomcat_lcAdmin/work/Catalina/* echo "开始更新文件" unzip ${S_DIR}/lcAdmin.war -d /opt/tomcat_lcAdmin/onlineapp/lcAdmin echo "================更新完成,开始启动服务==================" cd /opt/ ./tomcat_lcAdmin/bin/catalina.sh start if [ "$?" == "0" ]; then echo "启动成功,请检查启动日志" tail -f /opt/tomcat_lcAdmin/logs/catalina.out else echo "启动失败,请检查服务" exit 0 fi } function full_timer { echo "======================关闭定时器应用=====================" cd /opt/ ./tomcat_timer/bin/catalina.sh stop sleep 3 kill -9 ${TIM_PID} if [ "${TIM_PID}" == "" ]; then echo "tomcat is stopd" else echo "tomcat is not stopd Please Check!" exit 0 fi cd tomcat_timer/onlineapp/ rm -rf timer/* echo "删除缓存文件" rm -rf /opt/tomcat_timer/temp/* /opt/tomcat_timer/work/Catalina/* echo "开始更新文件" unzip ${S_DIR}/lcTimer.war -d /opt/tomcat_lcAdmin/onlineapp/timer echo "================更新完成,开始启动服务==================" cd /opt/ ./tomcat_timer/bin/catalina.sh start if [ "$?" == "0" ]; then echo "启动成功,请检查启动日志" tail -f /opt/tomcat_timer/logs/catalina.out else echo "启动失败,请检查服务" exit 0 fi } function full_dubbo2 { echo "======================关闭DUBBO应用=====================" cd /opt/ ./tomcat_dubbo2/bin/catalina.sh stop sleep 3 kill -9 ${DU_PID} if [ "${DU_PID}" == "" ]; then echo "tomcat is stopd" else echo "tomcat is not stopd Please Check!" exit 0 fi cd tomcat_dubbo2/onlineapp/ rm -rf dubbo2/* echo "删除缓存文件" rm -rf /opt/tomcat_dubbo2/temp/* /opt/tomcat_dubbo2/work/Catalina/* echo "开始更新文件" unzip ${S_DIR}/dubboMainServer.war -d /opt/tomcat_dubbo2/onlineapp/dubbo2 echo "================更新完成,开始启动服务==================" cd /opt/ ./tomcat_dubbo2/bin/catalina.sh start if [ "$?" == "0" ]; then echo "启动成功,请检查启动日志" tail -f /opt/tomcat_dubbo2/logs/catalina.out else echo "启动失败,请检查服务" exit 0 fi } yd_bak; if [ "${IP}" == "139.196.153.10" ] then echo "理财 app Pid is ${LC_PID}" echo "贷款 Pid is ${DK_PID}" echo "DUBBO Pid is ${DU_PID}" read -p "Please choese the update file: lcapp,dkapp,dubbo" FILE case ${FILE} in lcApp|lcapp) { full_lc };; dkApp|dkapp) { full_dk };; dubbo1|dubbo) { full_dubbo };; *) echo "Sorry! can not find ${FILE} or No such file " esac else echo "DUBBO Pid is ${DU_PID}" echo "定时器Pid is ${TIM_PID}" echo "理财后台 Pid is ${LCAD_PID}" read -p "Please choese the update file: lcadmin,dubbo2,timer" FILE case ${FILE} in lcadmin) { full_lcadmin };; dubbo2) { full_dubbo2 };; timer) { full_timer };; *) echo "Sorry! can not find ${FILE} or No such file " esac fi
tomcat程序全量更新脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。