kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [04/23] kylin git commit: KYLIN-2573 'kylin.sh stop' can't kill kylin's process by sometimes.
Date Fri, 12 May 2017 05:22:19 GMT
KYLIN-2573 'kylin.sh stop' can't kill kylin's process by sometimes.

Signed-off-by: Billy Liu <billyliu@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/38b076da
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/38b076da
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/38b076da

Branch: refs/heads/2.0.x-hbase0.98
Commit: 38b076dafa56ecf1963f71854e7b01da3a0a8be5
Parents: c41c2d7
Author: mango77881 <12169101@qq.com>
Authored: Fri May 5 15:25:56 2017 +0800
Committer: Billy Liu <billyliu@apache.org>
Committed: Tue May 9 13:49:51 2017 +0800

----------------------------------------------------------------------
 build/bin/kylin.sh | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/38b076da/build/bin/kylin.sh
----------------------------------------------------------------------
diff --git a/build/bin/kylin.sh b/build/bin/kylin.sh
index f30b751..63b5796 100644
--- a/build/bin/kylin.sh
+++ b/build/bin/kylin.sh
@@ -127,20 +127,47 @@ then
     if [ -f "${KYLIN_HOME}/pid" ]
     then
         PID=`cat $KYLIN_HOME/pid`
+        WAIT_TIME=2
+        LOOP_COUNTER=10
         if ps -p $PID > /dev/null
         then
-           echo "Stopping Kylin: $PID"
-           kill $PID
-           rm ${KYLIN_HOME}/pid
-           exit 0
+            echo "Stopping Kylin: $PID"
+            kill $PID
+
+            for ((i=0; i<$LOOP_COUNTER; i++))
+            do
+                # wait to process stopped 
+                sleep $WAIT_TIME
+                if ps -p $PID > /dev/null ; then
+                    echo "Stopping in progress. Will check after $WAIT_TIME secs again..."
+                    continue;
+                else
+                    break;
+                fi
+            done
+
+            # if process is still around, use kill -9
+            if ps -p $PID > /dev/null
+            then
+                echo "Initial kill failed, getting serious now..."
+                kill -9 $PID
+                sleep 1 #give kill -9  sometime to "kill"
+                if ps -p $PID > /dev/null
+                then
+                   quit "Warning, even kill -9 failed, giving up! Sorry..."
+                fi
+            fi
+
+            # process is killed , remove pid file		
+            rm -rf ${KYLIN_HOME}/pid
+            echo "Kylin with pid ${PID} has been stopped."
+            exit 0
         else
-           quit "Kylin is not running"
+           quit "Kylin with pid ${PID} is not running"
         fi
-        
     else
         quit "Kylin is not running"
     fi
-
 elif [ "$1" = "version" ]
 then
     retrieveDependency


Mime
View raw message