ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From me...@apache.org
Subject [2/2] ranger git commit: RANGER-2229 : Perform graceful terminate with retries before doing forceful kill for usersync and tagsync
Date Mon, 08 Oct 2018 14:39:26 GMT
RANGER-2229 : Perform graceful terminate with retries before doing forceful kill for usersync
and tagsync

Change-Id: I5608a64dec91f7ccbd85cc8a671158f9c0764dc2

Signed-off-by: Mehul Parikh <mehul@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/6c6650c3
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/6c6650c3
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/6c6650c3

Branch: refs/heads/ranger-1.1
Commit: 6c6650c32bd26fa891fe8f7c22f42d0577f41dbe
Parents: d1dd837
Author: Bhavik Patel <bhavikpatel552@gmail.com>
Authored: Wed Sep 19 16:05:32 2018 +0530
Committer: Mehul Parikh <mehul@apache.org>
Committed: Mon Oct 8 20:09:01 2018 +0530

----------------------------------------------------------------------
 tagsync/scripts/ranger-tagsync-services.sh      | 44 +++++++++++++++-----
 .../scripts/ranger-usersync-services.sh         | 41 ++++++++++++++----
 2 files changed, 67 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/6c6650c3/tagsync/scripts/ranger-tagsync-services.sh
----------------------------------------------------------------------
diff --git a/tagsync/scripts/ranger-tagsync-services.sh b/tagsync/scripts/ranger-tagsync-services.sh
index 5686390..a4ad7b1 100755
--- a/tagsync/scripts/ranger-tagsync-services.sh
+++ b/tagsync/scripts/ranger-tagsync-services.sh
@@ -111,17 +111,41 @@ elif [ "${action}" == "STOP" ]; then
 	NR_ITER_FOR_SHUTDOWN_CHECK=15
 	if [ -f "$pidf" ] ; then
 		pid=`cat $pidf` > /dev/null 2>&1
-		echo "Found Apache Ranger TagSync Service with pid $pid, Stopping..."
-		kill -9 $pid > /dev/null 2>&1
-		sleep 1 #Give kill -9 sometime to "kill"
-		if ps -p $pid > /dev/null; then
-			echo "Wow, even kill -9 failed, giving up! Sorry.."
-                else
-			rm -f $pidf
-			echo "Apache Ranger Tagsync Service pid = ${pid} has been stopped."
-                fi
+		echo "Getting pid from $pidf .."
 	else
-            echo "Ranger Tagsync Service not running"
+		pid=`ps -ef | grep java | grep -- '-Dproc_rangertagsync' | grep -v grep | awk '{ print
$2 }'`
+		if [ "$pid" != "" ];then
+			echo "pid file($pidf) not present, taking pid from \'ps\' command.."
+		else
+			echo "Apache Ranger Tagsync Service is not running"
+			exit 1	
+		fi
+	fi
+	echo "Found Apache Ranger Tagsync Service with pid $pid, Stopping it..."
+	kill -15 $pid
+	for ((i=0; i<$NR_ITER_FOR_SHUTDOWN_CHECK; i++))
+	do
+		sleep $WAIT_TIME_FOR_SHUTDOWN
+		if ps -p $pid > /dev/null ; then
+			echo "Shutdown in progress. Will check after $WAIT_TIME_FOR_SHUTDOWN 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
+	fi
+	sleep 1 #give kill -9  sometime to "kill"
+	if ps -p $pid > /dev/null ; then
+		echo "Wow, even kill -9 failed, giving up! Sorry.."
+		exit 1
+
+	else
+		rm -rf $pidf
+		echo "Apache Ranger Tagsync Service with pid ${pid} has been stopped."
 	fi
 	exit;
 	

http://git-wip-us.apache.org/repos/asf/ranger/blob/6c6650c3/unixauthservice/scripts/ranger-usersync-services.sh
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/ranger-usersync-services.sh b/unixauthservice/scripts/ranger-usersync-services.sh
index 028ad08..476aa0c 100644
--- a/unixauthservice/scripts/ranger-usersync-services.sh
+++ b/unixauthservice/scripts/ranger-usersync-services.sh
@@ -129,18 +129,43 @@ if [ "${action}" == "START" ]; then
 elif [ "${action}" == "STOP" ]; then
 	WAIT_TIME_FOR_SHUTDOWN=2
 	NR_ITER_FOR_SHUTDOWN_CHECK=15
-	if [ -f $pidf ]; then
+	if [ -f "$pidf" ] ; then
 		pid=`cat $pidf` > /dev/null 2>&1
-		kill -9 $pid > /dev/null 2>&1
-		sleep 1 #Give kill -9 sometime to "kill"
-		if ps -p $pid > /dev/null; then
-			echo "Wow, even kill -9 failed, giving up! Sorry.."
+		echo "Getting pid from $pidf .."
+	else
+		pid=`ps -ef | grep java | grep -- '-Dproc_rangerusersync' | grep -v grep | awk '{ print
$2 }'`
+		if [ "$pid" != "" ];then
+			echo "pid file($pidf) not present, taking pid from \'ps\' command.."
 		else
-			rm -f $pidf
-			echo "Apache Ranger Usersync Service [pid = ${pid}] has been stopped."
+			echo "Apache Ranger Usersync Service is not running"
+			exit 1	
 		fi
+	fi
+	echo "Found Apache Ranger Usersync Service with pid $pid, Stopping it..."
+	kill -15 $pid
+	for ((i=0; i<$NR_ITER_FOR_SHUTDOWN_CHECK; i++))
+	do
+		sleep $WAIT_TIME_FOR_SHUTDOWN
+		if ps -p $pid > /dev/null ; then
+			echo "Shutdown in progress. Will check after $WAIT_TIME_FOR_SHUTDOWN 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
+	fi
+	sleep 1 #give kill -9  sometime to "kill"
+	if ps -p $pid > /dev/null ; then
+		echo "Wow, even kill -9 failed, giving up! Sorry.."
+		exit 1
+
 	else
-		echo "Apache Ranger Usersync Service not running"
+		rm -rf $pidf
+		echo "Apache Ranger Usersync Service with pid ${pid} has been stopped."
 	fi
 	exit;
 	


Mime
View raw message