forked from jmscott/blobio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron-reboot
55 lines (44 loc) · 1.13 KB
/
cron-reboot
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
#
# Synopsis:
# Cron script to fully reboot all blob process @reboot cron schedule
# Usage:
# # in crontab
# BLOBIO_ROOT=/usr/local/blobio
# @reboot $BLOBIO_ROOTsbin/cron-reboot \
# >>$BLOBIO_ROOT/log/cron-reboot.log 2>&1
#
PROG=$(basename $0)
USER=$(id -un)
log()
{
echo "$(date +'%Y/%m/%d %H:%M:%S'): $PROG#$$: $@"
}
die()
{
log "ERROR: $@" >&2
exit 1
}
leave()
{
log 'good bye, cruel world'
}
log 'hello, world'
trap leave EXIT
test -n "$BLOBIO_ROOT" || die "environment variable not defined: BLOBIO_ROOT"
log "BLOBIO_ROOT=$BLOBIO_ROOT"
cd $BLOBIO_ROOT || die "cd $BLOBIO_ROOT failed"
. etc/profile
zap-proc run/flowd.pid || die "zap-proc flowd failed: exit status=$?"
log 'calling biod_ctl reboot ...'
biod_ctl reboot
test $? = 0 || die "biod_ctl reboot failed: exit status=$STATUS"
log 'biod_ctl reboot ok'
log 'starting flowd server in background ...'
flowd server etc/blobio.flow &
FLOWD_PID=$!
log "flowd server process id is $FLOWD_PID"
echo $FLOWD_PID >run/flowd.pid ||
die "echo $FLOWD_PID >run/flowd.pid failed: exit status=$?"
log 'reboot sync flowd processes'
reboot-sync || die "reboot-sync failed: exit status=$?"
exit 0