summaryrefslogtreecommitdiffstats
path: root/extras/stop-all-gluster-processes.sh
blob: 25dc0ba6bf6f953006473ed64976d9a3c620d685 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /bin/sh

function main()
{
    errors=0;

    for pidfile in $(find /var/lib/glusterd/ -iname '*pid');
    do
        pid=$(cat ${pidfile});
        echo "sending SIGTERM to process $pid";
        kill -TERM $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
    gsyncpid=`ps aux | grep gluster | grep gsync | awk '{print $2}'`;
    if [ -n "$gsyncpid" ]
    then
        kill -TERM $gsyncpid || errors=$(($errors + 1));
    fi

    sleep 5;

    # if pid file still exists, its something to KILL
    for pidfile in $(find /var/lib/glusterd/ -iname '*pid');
    do
        pid=$(cat ${pidfile});
        echo "sending SIGKILL to process $pid";
        kill -KILL $pid;
    done

    # handle 'KILL' of geo-replication
    gsyncpid=`ps aux | grep gluster | grep gsync | awk '{print $2}'`;
    if [ -n "$gsyncpid" ]
    then
        kill -KILL $gsyncpid || errors=$(($errors + 1));
    fi

    exit $errors;
}

main "$@";