-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathssctl
76 lines (63 loc) · 1.35 KB
/
ssctl
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
70
71
72
73
74
75
76
#!/usr/bin/env bash
#
# Synopsis:
# Manually start/stop/restart processes for SetSpace
# Usage:
# ssctl start # start the world, aborting on the first error
# ssctl stop # stop all processes
#
PROG=$(basename $0)
PKILL_PAUSE=10
log()
{
MSG=$@
test -n "$SCHEMA" && MSG="$SCHEMA: $MSG"
echo "$(date +'%Y/%m/%d %H:%M:%S'): $MSG"
}
die()
{
log "ERROR: $@" >&2
exit 1
}
leave()
{
log 'good bye, cruel world'
}
test $# = 1 || die "wrong arg count: expect 1, got $#"
ACTION=$1
log 'hello, world'
trap leave EXIT
log "action: $ACTION"
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
log "path to flowd: $(which flowd)"
# shutdown any flowd processes
case "$ACTION" in
start)
# start up a flowd process for each flow file in
# schema/$SCHEMA/etc/$SCHEMA.flow
log 'finding startable schemas ...'
ls-start-flowd | while read SCHEMA; do
log "schema: $SCHEMA"
start-flowd $SCHEMA || die "start-flowd failed: exit status=$?"
done
log 'all flowds started'
;;
stop)
log 'stopping UP/ZOMBIE flowds ...'
stop-all-flowd || die "stop-all-flowd failed: exit status=$?"
;;
restart)
log 'restarting setspace process ...'
ssctl stop && ssctl start
;;
*)
die "unknown action: $ACTION"
;;
esac
echo
run-stat-report
echo