-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstop-all-flowd
executable file
·69 lines (59 loc) · 1.24 KB
/
stop-all-flowd
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# Synopsis:
# Gracefull stop all flowd proesses
# Usage:
# stop-all-flowd
# Blame:
# jmscott@setspace.com
# setspace@gmail.com
# Note:
# Think about overriding name of SETSPACE_ROOT my consulting a variable
# named SETSPACE_ROOT_NAME. Will be helpfull for non setspace
# schemas that wish to manage flowd process.
#
PROG=$(basename $0)
log()
{
MSG=$@
test -n "$SCHEMA" && MSG="$SCHEMA: $MSG"
echo "$(date +'%Y/%m/%d %H:%M:%S'): $PROG: $MSG"
}
die()
{
log "ERROR: $@" >&2
exit 1
}
leave()
{
log 'good bye, cruel world'
}
test $# = 0 || die 'wrong number of arguments'
log 'hello, world'
trap leave EXIT
test -n "$SETSPACE_ROOT" ||
die "environment variable not defined: SETSPACE_ROOT"
log "SETSPACE_ROOT=$SETSPACE_ROOT"
cd $SETSPACE_ROOT || die "cd $SETSPACE_ROOT failed"
. etc/profile
run-stat-report |
grep '^[a-z][a-z0-9_]* ' |
cut -f1,2 |
grep -F -wv 'DOWN' |
grep -F -wv 'OFFL' |
sort |
while read SCHEMA STATE; do
log "stop flowd of schema: $SCHEMA ($STATE)"
stop-flowd $SCHEMA
STATUS=$?
case $STATUS in
0)
log "stopped flowd process: $SCHEMA"
;;
1)
log "no flowd process was running (ok)"
;;
*)
die "stop-flowd $SCHEMA failed: exit status=$STATUS"
;;
esac
done