Showing
1 changed file
with
99 additions
and
99 deletions
1 | -#!/bin/bash | ||
2 | -################################################################ | ||
3 | -#@Authro Lijian | ||
4 | -#@Date 2007-05-22 | ||
5 | -################################################################ | ||
6 | - | ||
7 | -BASE_BIN_DIR=`dirname $0` | ||
8 | -#import home var env | ||
9 | -. $BASE_BIN_DIR/env.sh | ||
10 | - | ||
11 | -TIMESTAMP=`date +%Y_%m_%d_%H:%M` | ||
12 | -HOST_NAME=`hostname` | ||
13 | -LOG_DIR=$WEB_APP_HOME/logs | ||
14 | -JBOSS_CHECK_LOG="$LOG_DIR/jboss_stdout.log" | ||
15 | -JBOSS_BASE_DIR=$WEB_APP_HOME/.jboss/default | ||
16 | -TOMCAT_BASE_DIR=$WEB_APP_HOME/.tomcat | ||
17 | -LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"` | ||
18 | -REMOVE_URL="http://api.yoho.yohoops.org/service_control/unregister?ip=$LOCAL_IP&context=$SERVER_NAMESPACE" | ||
19 | - | ||
20 | - | ||
21 | -stop_jboss() | ||
22 | -{ | ||
23 | - JBOSS_JAVA_PID=`get_jboss_pid` | ||
24 | - if [ ! -z "$JBOSS_JAVA_PID" ] ; then | ||
25 | - echo -e "$HOST_NAME: stopping jboss ...\c" | ||
26 | - $JBOSS_HOME/bin/jboss-cli.sh --connect controller=localhost:$NAMING_PORT command=:shutdown > /dev/null 2>&1 | ||
27 | - LOOPS=0 | ||
28 | - while [ $LOOPS -lt 30 ]; do | ||
29 | - printProcess | ||
30 | - kill -s 0 $JBOSS_JAVA_PID > /dev/null 2>&1 | ||
31 | - if [ $? -eq 1 ]; then | ||
32 | - break | ||
33 | - fi | ||
34 | - let LOOPS=LOOPS+1 | ||
35 | - done | ||
36 | - | ||
37 | - JBOSS_JAVA_PID=`get_jboss_pid` | ||
38 | - if [ ! -z "$JBOSS_JAVA_PID" ] ; then | ||
39 | - echo -e "[INFO] kill java process $JBOSS_JAVA_PID .\c" | ||
40 | - kill -9 $JBOSS_JAVA_PID > /dev/null 2>&1 | ||
41 | - fi | ||
42 | - success "Oook!" | ||
43 | - else | ||
44 | - warning "[WARN] $HOST_NAME: jboss not running, who care?" | ||
45 | - fi | ||
46 | -} | ||
47 | - | ||
48 | -get_jboss_pid(){ | ||
49 | - STR=`ps -C java -f --width 1000 | grep "$JBOSS_BASE_DIR"|awk '{print $2}'` | ||
50 | - echo $STR | ||
51 | -} | ||
52 | - | ||
53 | -get_tomcat_pid(){ | ||
54 | - STR=`ps -C java -f --width 1000 | grep "$TOMCAT_BASE_DIR"|awk '{print $2}'` | ||
55 | - echo $STR | ||
56 | -} | ||
57 | - | ||
58 | -stop_tomcat(){ | ||
59 | - TOMCAT_JAVA_PID=`get_tomcat_pid` | ||
60 | - if [ ! -z "$TOMCAT_JAVA_PID" ] ; then | ||
61 | - | ||
62 | - | ||
63 | - success "start to remove service register from zookeeper: $REMOVE_URL" | ||
64 | - curl -m 10 -s -o /dev/null "$REMOVE_URL" | ||
65 | - sleep 5s | ||
66 | - success "success to remove $LOCAL_IP" | ||
67 | - | ||
68 | - | ||
69 | - #echo -e "$HOST_NAME: stopping tomcat ...\c" | ||
70 | - #$SERVER_HOME/bin/catalina.sh stop > /dev/null 2>&1 | ||
71 | - #LOOPS=0 | ||
72 | - #while [ $LOOPS -lt 30 ]; do | ||
73 | - #printProcess | ||
74 | - #kill -s 0 $TOMCAT_JAVA_PID > /dev/null 2>&1 | ||
75 | - #if [ $? -eq 1 ]; then | ||
76 | - #break | ||
77 | - #fi | ||
78 | - #let LOOPS=LOOPS+1 | ||
79 | - #done | ||
80 | - | ||
81 | - #TOMCAT_JAVA_PID=`get_tomcat_pid` | ||
82 | - #if [ ! -z "$TOMCAT_JAVA_PID" ] ; then | ||
83 | - echo -e "[INFO] kill java process $TOMCAT_JAVA_PID .\c" | ||
84 | - kill -9 $TOMCAT_JAVA_PID > /dev/null 2>&1 | ||
85 | - #fi | ||
86 | - success "Oook!" | ||
87 | - else | ||
88 | - warning "[WARN] $HOST_NAME: tomcat not running, who care?" | ||
89 | - fi | ||
90 | -} | ||
91 | - | ||
92 | - | ||
93 | -if [ $SERVER_TYPE = "jboss" ]; then | ||
94 | - stop_jboss | ||
95 | -fi | ||
96 | - | ||
97 | -if [ $SERVER_TYPE = "tomcat" ]; then | ||
98 | - stop_tomcat | ||
99 | -fi | 1 | +#!/bin/bash |
2 | +################################################################ | ||
3 | +#@Authro Lijian | ||
4 | +#@Date 2007-05-22 | ||
5 | +################################################################ | ||
6 | + | ||
7 | +BASE_BIN_DIR=`dirname $0` | ||
8 | +#import home var env | ||
9 | +. $BASE_BIN_DIR/env.sh | ||
10 | + | ||
11 | +TIMESTAMP=`date +%Y_%m_%d_%H:%M` | ||
12 | +HOST_NAME=`hostname` | ||
13 | +LOG_DIR=$WEB_APP_HOME/logs | ||
14 | +JBOSS_CHECK_LOG="$LOG_DIR/jboss_stdout.log" | ||
15 | +JBOSS_BASE_DIR=$WEB_APP_HOME/.jboss/default | ||
16 | +TOMCAT_BASE_DIR=$WEB_APP_HOME/.tomcat | ||
17 | +LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"` | ||
18 | +REMOVE_URL="$GW_URL/service_control/unregister?ip=$LOCAL_IP&context=$SERVER_NAMESPACE" | ||
19 | + | ||
20 | + | ||
21 | +stop_jboss() | ||
22 | +{ | ||
23 | + JBOSS_JAVA_PID=`get_jboss_pid` | ||
24 | + if [ ! -z "$JBOSS_JAVA_PID" ] ; then | ||
25 | + echo -e "$HOST_NAME: stopping jboss ...\c" | ||
26 | + $JBOSS_HOME/bin/jboss-cli.sh --connect controller=localhost:$NAMING_PORT command=:shutdown > /dev/null 2>&1 | ||
27 | + LOOPS=0 | ||
28 | + while [ $LOOPS -lt 30 ]; do | ||
29 | + printProcess | ||
30 | + kill -s 0 $JBOSS_JAVA_PID > /dev/null 2>&1 | ||
31 | + if [ $? -eq 1 ]; then | ||
32 | + break | ||
33 | + fi | ||
34 | + let LOOPS=LOOPS+1 | ||
35 | + done | ||
36 | + | ||
37 | + JBOSS_JAVA_PID=`get_jboss_pid` | ||
38 | + if [ ! -z "$JBOSS_JAVA_PID" ] ; then | ||
39 | + echo -e "[INFO] kill java process $JBOSS_JAVA_PID .\c" | ||
40 | + kill -9 $JBOSS_JAVA_PID > /dev/null 2>&1 | ||
41 | + fi | ||
42 | + success "Oook!" | ||
43 | + else | ||
44 | + warning "[WARN] $HOST_NAME: jboss not running, who care?" | ||
45 | + fi | ||
46 | +} | ||
47 | + | ||
48 | +get_jboss_pid(){ | ||
49 | + STR=`ps -C java -f --width 1000 | grep "$JBOSS_BASE_DIR"|awk '{print $2}'` | ||
50 | + echo $STR | ||
51 | +} | ||
52 | + | ||
53 | +get_tomcat_pid(){ | ||
54 | + STR=`ps -C java -f --width 1000 | grep "$TOMCAT_BASE_DIR"|awk '{print $2}'` | ||
55 | + echo $STR | ||
56 | +} | ||
57 | + | ||
58 | +stop_tomcat(){ | ||
59 | + TOMCAT_JAVA_PID=`get_tomcat_pid` | ||
60 | + if [ ! -z "$TOMCAT_JAVA_PID" ] ; then | ||
61 | + | ||
62 | + | ||
63 | + success "start to remove service register from zookeeper: $REMOVE_URL" | ||
64 | + curl -m 10 -s -o /dev/null "$REMOVE_URL" | ||
65 | + sleep 5s | ||
66 | + success "success to remove $LOCAL_IP" | ||
67 | + | ||
68 | + | ||
69 | + #echo -e "$HOST_NAME: stopping tomcat ...\c" | ||
70 | + #$SERVER_HOME/bin/catalina.sh stop > /dev/null 2>&1 | ||
71 | + #LOOPS=0 | ||
72 | + #while [ $LOOPS -lt 30 ]; do | ||
73 | + #printProcess | ||
74 | + #kill -s 0 $TOMCAT_JAVA_PID > /dev/null 2>&1 | ||
75 | + #if [ $? -eq 1 ]; then | ||
76 | + #break | ||
77 | + #fi | ||
78 | + #let LOOPS=LOOPS+1 | ||
79 | + #done | ||
80 | + | ||
81 | + #TOMCAT_JAVA_PID=`get_tomcat_pid` | ||
82 | + #if [ ! -z "$TOMCAT_JAVA_PID" ] ; then | ||
83 | + echo -e "[INFO] kill java process $TOMCAT_JAVA_PID .\c" | ||
84 | + kill -9 $TOMCAT_JAVA_PID > /dev/null 2>&1 | ||
85 | + #fi | ||
86 | + success "Oook!" | ||
87 | + else | ||
88 | + warning "[WARN] $HOST_NAME: tomcat not running, who care?" | ||
89 | + fi | ||
90 | +} | ||
91 | + | ||
92 | + | ||
93 | +if [ $SERVER_TYPE = "jboss" ]; then | ||
94 | + stop_jboss | ||
95 | +fi | ||
96 | + | ||
97 | +if [ $SERVER_TYPE = "tomcat" ]; then | ||
98 | + stop_tomcat | ||
99 | +fi |
-
Please register or login to post a comment