forked from stuartlynne/racedb_qlmuxd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
standby.sh
executable file
·74 lines (60 loc) · 1.98 KB
/
standby.sh
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
#!/bin/bash
#set -x
export ROLE="standby"
. ./scripts/common.sh
# ###############################################################################################################################
failover() {
stderr "Configuring Failover"
set -x
touch "${TRIGGERPATH}"
set +x
}
# ###############################################################################################################################
if [ ${POSTGRESQL_RACEDB_PRIMARY_RUNNING} -eq 1 ] ; then
stderr
stderr "PRIMARY Containers are running, cannot run STANDBY at the same time"
stderr "Use ./primary.sh stop first if you wish to use the STANDBY container set"
stderr
exit 1
fi
# ###############################################################################################################################
# Not Running
usage_notrunning() {
stderr
stderr "${ARG0} Commands:"
stderr
stderr " help - display usage"
stderr " start - start ${role} RaceDB container set"
stderr
exit 0
}
if [ ! ${POSTGRESQL_RACEDB_STANDBY_RUNNING} -eq 1 ] ; then
case "${CMD}" in
start ) start;;
help | *) usage_notrunning;;
esac
exit 0
fi
# ###############################################################################################################################
# Running
usage_running() {
stderr
stderr "${ARG0} Commands:"
stderr " help - display usage"
stderr " restart - stop and restart RaceDB as ${ROLE^^}"
stderr " stop - stop RaceDB as ${ROLE^^}"
stderr " failover - promote STANDBY server to FAILOVER PRIMARY"
}
if [ ${POSTGRESQL_RACEDB_STANDBY_RUNNING} -eq 1 ] ; then
case "${ROLE}-${CMD}" in
restore-sql) restore_sql ${*} ;;
esac
case "${CMD}" in
restart ) restart ;;
stop ) stop ;;
failover | fail | fall | fallover ) failover;;
help | *) usage_running;;
esac
exit 0
fi
exit 0