|
In order to do cluster testing, each machine is equipped with a three tomcat, each release project must be repeated when knocking some order, first check before restarting tomcat tomcat process has not stopped, not even manually kill the process.
Released several times, the operation is more complicated, and simply write a script to a key release, saving time and effort.
The deploy.sh and restart.sh are copied to the three tomcat bin directory, and then chmod + x to both conferred on the script executable permissions.
Post a key command: ./ deploy.sh project war package, such as: ./ deploy.sh /home/test.war
Description: deploy.sh ROOT directory will be emptied under the tomcat, and then pressurized to the specified war package ROOT directory, and finally execute restart.sh restart tomcat.
Code is as follows:
1 #! / Bin / sh
2
3 war = $ 1
4 bin = $ (cd `dirname $ 0`; pwd)
5
6 if [-n "$ {war}"!]; Then
7 echo "*** Usage: $ 0 [project.war]"
8 exit 0
9 fi
10 if [-f "$ {war}"!]; Then
11 echo "*** Error: $ {war} does not exist."
12 exit 0
13 fi
14 if [! "$ {. War ## *}" = "war"]; then
15 echo "*** Error: $ {war} is not a war file."
16 exit 0
17 fi
18
19 echo "Deploy $ {war ## * /} ..."
20 rm -rf $ {bin} /../ webapps / ROOT / && unzip -qo $ {war} -d $ {bin} /../ webapps / ROOT /
21 rm -rf $ {bin} /../ work / Catalina / localhost /
22 echo "Restart tomcat ..."
$ 23 exec {bin} /restart.sh
To restart the tomcat use the command: ./ (print tomcat start the log indicating that the startup parameter -v) restart.sh or ./restart.sh -v
Description: restart.sh is used to restart the tomcat, tomcat does not start if it is started directly, if you have started on the first shutdown restart after shutdown 3s if not stopped tomcat process, then kill off the original process restarted.
Code is as follows:
1 #! / Bin / sh
2
3 bin = $ (cd `dirname $ 0`; pwd)
4 pid = $ (ps aux | grep tomcat | grep -v grep | grep -v restart | grep $ {bin} | awk '{print $ 2}')
5
6 if [-n "$ {pid}"]; then
7 echo "Shutdown ..."
8 sh $ {bin} /shutdown.sh
9 sleep 3
10
11 pid = $ (ps aux | grep tomcat | grep -v grep | grep -v restart | grep $ {bin} | awk '{print $ 2}')
12 if [-n "$ {pid}"]; then
13 kill -9 $ {pid}
14 sleep 1
15 fi
16 fi
17
18 echo "Startup ..."
$ 19 sh {bin} /startup.sh
20 if [ "$ 1" = "-v"]; then
21 tail -f $ {bin} /../ logs / catalina.out
22 fi
I am using CentOS, 3 Ge tomcat respectively at 8080/8081/8082 subdirectory /opt/apache-tomcat-7.0.65/ under 8080/8081/8082 listening port.
Finally, in the browser, type http: // localhost: 8080 to access. |
|
|
|