forked from eloots/Pi-Akka-Cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopNode
executable file
·32 lines (25 loc) · 836 Bytes
/
stopNode
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
#!/bin/bash
######################################################################
# Usage:
# stopNode [node-nr] [signal-nr]
#
# node-nr: relative nr. of node (0 .. 4)
# signal-nr: defaults to 2 (SIGINT)
#
# Note: Set environment variable CLUSTER_NR to the number of your
# Akka Cluster
######################################################################
# Set CLUSTER_NR to the number of the cluster you're working with
CLUSTER_NR_SEL=${CLUSTER_NR:-0}
CLUSTER_BASE_NODE_NR=$(expr $CLUSTER_NR_SEL \* 5)
PI_USER=akkapi
SELECTED_SIGNAL=$2
SIGNAL=${SELECTED_SIGNAL:-2}
ALL_NODES="0 1 2 3 4"
SELECTED_NODE=$1
NODES=${SELECTED_NODE:-$ALL_NODES}
for i in $NODES;do
node=$[ CLUSTER_BASE_NODE_NR + i ]
echo "Stopping node-${node}"
ssh ${PI_USER}@node-${node} "sudo pkill -${SIGNAL} -f .\*_[0-9][0-9][0-9]_.\*"
done