-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
53 lines (42 loc) · 1.44 KB
/
start.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
#!/usr/bin/env bash
set -e
function log {
echo `date` $ME - $@
}
function checkrancher {
log "checking rancher network..."
a="`ip a s dev eth0 &> /dev/null; echo $?`"
while [ $a -eq 1 ];
do
a="`ip a s dev eth0 &> /dev/null; echo $?`"
sleep 1
done
b="`ping -c 1 rancher-metadata &> /dev/null; echo $?`"
while [ $b -eq 1 ];
do
b="`ping -c 1 rancher-metadata &> /dev/null; echo $?`"
sleep 1
done
}
CONFD_BACKEND=${CONFD_BACKEND:-"zookeeper"}
CONFD_BACKEND_SERVER=${CONFD_BACKEND_SERVER:-"zookeeper:2181"}
CONFD_PREFIX=${CONFD_PREFIX:-"/"}
CONFD_INTERVAL=${CONFD_INTERVAL:-5}
CONFD_PARAMS=${CONFD_PARAMS:-"-backend ${CONFD_BACKEND} -prefix ${CONFD_PREFIX} -node ${CONFD_BACKEND_SERVER}"}
CONFD_ONETIME="/usr/bin/confd -onetime ${CONFD_PARAMS}"
CONFD_SCRIPT=${CONFD_SCRIPT:-"/usr/bin/confd-start.sh"}
CONFD_PARAMS="-interval ${CONFD_INTERVAL} ${CONFD_PARAMS}"
export CONFD_BACKEND CONFD_BACKEND_SERVER CONFD_PREFIX CONFD_INTERVAL CONFD_PARAMS
checkrancher
# Create confd start script
echo "#!/usr/bin/env sh" > ${CONFD_SCRIPT}
echo "/usr/bin/nohup /usr/bin/confd ${CONFD_PARAMS} > /opt/vamp/confd.log 2>&1 &" >> ${CONFD_SCRIPT}
echo "rc=\$?" >> ${CONFD_SCRIPT}
echo "echo \$rc" >> ${CONFD_SCRIPT}
chmod 755 ${CONFD_SCRIPT}
# Run confd to get first appli configuration
log "[ Getting haproxy configuration... ]"
${CONFD_ONETIME}
# Run monit
log "[ Starting monit... ]"
/usr/bin/monit -I