summaryrefslogtreecommitdiffstats
path: root/extras/stop-all-gluster-processes.sh
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2016-05-10 12:59:56 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2016-05-13 15:07:10 -0700
commit48608e2ca1c6d681c0c60c71ae41b403554bb71d (patch)
treeb474030a5d4dc0aaa92f39f0d08bcadf05e3b17d /extras/stop-all-gluster-processes.sh
parent137bd83029458ecd461718a891c74cd1afd8f6cb (diff)
downloadglusterfs-48608e2ca1c6d681c0c60c71ae41b403554bb71d.tar.gz
glusterfs-48608e2ca1c6d681c0c60c71ae41b403554bb71d.tar.xz
glusterfs-48608e2ca1c6d681c0c60c71ae41b403554bb71d.zip
extras: stop all include glusterfs process as well
currently, extras/stop-all-gluster-processes.sh script handles brick processes, node services and geo-rep's gsync process. from now this script also handles mount processes as well, as part of this patch I have reorganized this script Change-Id: Id62d6fda6dd331bde722ce3d99ec3f09fed55cb0 BUG: 1334620 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-on: http://review.gluster.org/14277 Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'extras/stop-all-gluster-processes.sh')
-rwxr-xr-xextras/stop-all-gluster-processes.sh95
1 files changed, 68 insertions, 27 deletions
diff --git a/extras/stop-all-gluster-processes.sh b/extras/stop-all-gluster-processes.sh
index 25dc0ba6bf..5bc58b30f4 100755
--- a/extras/stop-all-gluster-processes.sh
+++ b/extras/stop-all-gluster-processes.sh
@@ -1,43 +1,84 @@
-#! /bin/sh
+#!/usr/bin/env bash
-function main()
+# global
+errors=0
+
+# find the mounts and return their pids
+function get_mount_pids()
{
- errors=0;
+ local opts
+ local pid
- for pidfile in $(find /var/lib/glusterd/ -iname '*pid');
+ for opts in $(grep -w fuse.glusterfs /proc/mounts| awk '{print $1":/"$2}');
do
- pid=$(cat ${pidfile});
- echo "sending SIGTERM to process $pid";
- kill -TERM $pid;
+ IFS=' ' read -r -a volinfo <<< $(echo "${opts}" | sed 's/:\// /g')
+ pid+="$(ps -Ao pid,args | grep -w "volfile-server=${volinfo[0]}" |
+ grep -w "volfile-id=/${volinfo[1]}" | grep -w "${volinfo[2]}" |
+ awk '{print $1}') "
done
+ echo "${pid}"
+}
- # for geo-replication, only 'monitor' has pid file written, other
- # processes are not having a pid file, so get it through 'ps' and
- # handle these processes
- gsyncpid=`ps aux | grep gluster | grep gsync | awk '{print $2}'`;
- if [ -n "$gsyncpid" ]
- then
- kill -TERM $gsyncpid || errors=$(($errors + 1));
- fi
+# handle mount processes i.e. 'glusterfs'
+function kill_mounts()
+{
+ local signal=${1}
+ local pid
- sleep 5;
+ for pid in $(get_mount_pids);
+ do
+ echo "sending SIG${signal} to mount process with pid: ${pid}";
+ kill -${signal} ${pid};
+ done
+}
+
+# handle brick processes and node services
+function kill_bricks_and_services()
+{
+ local signal=${1}
+ local pidfile
+ local pid
- # if pid file still exists, its something to KILL
- for pidfile in $(find /var/lib/glusterd/ -iname '*pid');
+ for pidfile in $(find /var/lib/glusterd/ -name '*.pid');
do
- pid=$(cat ${pidfile});
- echo "sending SIGKILL to process $pid";
- kill -KILL $pid;
+ local pid=$(cat ${pidfile});
+ echo "sending SIG${signal} to pid: ${pid}";
+ kill -${signal} ${pid};
done
+}
+
+# for geo-replication, only 'monitor' has pid file written, other
+# processes are not having a pid file, so get it through 'ps' and
+# handle these processes
+function kill_georep_gsync()
+{
+ local signal=${1}
- # handle 'KILL' of geo-replication
- gsyncpid=`ps aux | grep gluster | grep gsync | awk '{print $2}'`;
- if [ -n "$gsyncpid" ]
+ # FIXME: add strick/better check
+ local gsyncpid=$(ps -Ao pid,args | grep gluster | grep gsync |
+ awk '{print $1}');
+ if [ -n "${gsyncpid}" ]
then
- kill -KILL $gsyncpid || errors=$(($errors + 1));
+ echo "sending SIG${signal} to geo-rep gsync process ${gsyncpid}";
+ kill -${signal} ${gsyncpid} || errors=$((${errors} + 1));
fi
+}
+
+function main()
+{
+ kill_mounts TERM
+ kill_bricks_and_services TERM
+ kill_georep_gsync TERM
+
+ sleep 5;
+ echo ""
+
+ # still not Terminated? let's pass SIGKILL
+ kill_mounts KILL
+ kill_bricks_and_services KILL
+ kill_georep_gsync KILL
- exit $errors;
+ exit ${errors};
}
-main "$@";
+main