summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
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