summaryrefslogtreecommitdiffstats
path: root/extras
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-14 15:45:40 -0700
commit4b9f7d06fd22232affd0af4fd57351ee57b7c361 (patch)
treee79935a2999cda1868bcd139188421c3ae079113 /extras
parent11bb3c4e81e90cac48c4f083ec144354662927eb (diff)
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 Backport of: > 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> Change-Id: Id62d6fda6dd331bde722ce3d99ec3f09fed55cb0 BUG: 1334750 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-on: http://review.gluster.org/14320 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> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'extras')
-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 25dc0ba6bf6..5bc58b30f4e 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