单个tomcat多实例部署shell脚本_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 单个tomcat多实例部署shell脚本

单个tomcat多实例部署shell脚本

 2014/9/29 21:16:49  lean1252  程序员俱乐部  我要评论(0)
  • 摘要:引用步聚引用1.下载tomcat,解压安装引用2.将tomcat下的webapps,conf,temp等目录分别拷至根目录www下A,B,C目录下引用3.新建如下脚本restart_tomcat.sh引用4.使用restart_tomcat.shA/B/C#!/bin/shif[-z$1]thenecho-e"\033[31;1mpleaseinputtheappwhichyouneedrestart..
  • 标签:Tomcat 实例 Shell脚本 脚本

引用步聚
引用1. 下载tomcat,解压安装

引用2.将tomcat下的webapps,conf,temp等目录分别拷至根目录www下A,B,C目录下

引用3.新建如下脚本restart_tomcat.sh

引用4.使用restart_tomcat.sh A/B/C



class="java" name="code">

#!/bin/sh

if [ -z $1 ]
then
  echo -e "\033[31;1mplease input the app which you need restart...\033[0m"
  exit 1
fi

base_dir=/disk/www
CATALINA_HOME=$TOMCAT_HOME
if [ ! -d ${base_dir}/$1 ]; then
   echo -e "\033[31;1mcan't find the directory [${base_dir}/$1] or the [${base_dir}/$1] is no a directory, please check it...\033[0m"
   exit 1
fi

if [ ! -f ${base_dir}/$1/conf/server.xml ]; then
   echo -e "\033[31;1mcan't find the file [${base_dir}/$1/conf/server.xml] or the [${base_dir}/$1/conf/server.xml] is not a file, please check it...\033[0m"
   exit 1
fi

if [ ! -d ${base_dir}/$1/webapps ]; then
   echo -e "\033[31;1mcan't find the directory [${base_dir}/$1/webapps] or the [${base_dir}/$1/webapps] is not a directory, please check it...\033[0m"
   exit 1
fi

res=`ps aux | grep $1|grep "$JAVA_HOME/bin/java"|egrep -v "grep"|awk '{print $2}'`

if [ -z $res ]; then
   echo -e "\033[44;38;1mthe tomcat is not running, begin startup...\033[0m"
else
  echo -e '\033[45;35;1mcurrent running pid is' $res'...\033[0m'
   #ps aux | grep $1 | grep -v 'grep' &&
   ${CATALINA_HOME}/bin/shutdown.sh -config ${base_dir}/$1/conf/server.xml
   if [ $? -eq 0 ]; then
      echo -e "\033[44;38;1mtomcat shutdown successfully...\033[0m"
   else
      kill -9 `ps aux | grep $1 | grep -v grep | awk '{print $2}'` && echo -e "\033[44;38;1mtomcat killed sucess ..\033[0m"
   fi
fi

CATALINA_BASE=${base_dir}/$1
export CATALINA_BASE

if [ -f ${CATALINA}/setenv.sh ];then
  . "${CATALINA_BASE}/setenv.sh"
  echo "================="
else
  echo "+++++++++++++++++++==="
fi

${CATALINA_HOME}/bin/startup.sh -config ${base_dir}/$1/conf/server.xml && echo -e "\033[44;32;1mTomcat startup finished...\033[0m"
pid=`ps aux | grep $1|grep "$JAVA_HOME/bin/java"|egrep -v "grep"|awk '{print $2}'`
echo -e "\033[46;38;1mrunning pid is ${pid}...\033[0m"


发表评论
用户名: 匿名