-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdocker-entrypoint.sh
executable file
·78 lines (64 loc) · 2.28 KB
/
docker-entrypoint.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
75
76
77
78
#!/bin/bash
cluster=''
consulboot=0
consuljoinip=''
until [ -z "$1" ]
do
IFS='=' read -ra argarray <<< "$1"
if [ "${argarray[0]}" == '-cluster' ]; then
cluster="${argarray[1]}"
fi
if [ "${argarray[0]}" == '-consulboot' ]; then
consulboot=1
fi
if [ "${argarray[0]}" == '-consuljoinip' ]; then
consuljoinip="${argarray[1]}"
fi
shift
done
if [ ! -n "$cluster" ]; then
echo "Need Swift Cluster Name" && exit 1
fi
#consul
CONSUL_DATA_DIR="/app/consul/data"
CONSUL_BIND_INTERFACE="eth0"
CONSUL_BIND=
if [ -n "$CONSUL_BIND_INTERFACE" ]; then
CONSUL_BIND_ADDRESS=$(ip -o -4 addr list $CONSUL_BIND_INTERFACE | head -n1 | awk '{print $4}' | cut -d/ -f1)
if [ -z "$CONSUL_BIND_ADDRESS" ]; then
echo "Could not find IP for interface '$CONSUL_BIND_INTERFACE', exiting"
exit 1
fi
CONSUL_BIND="-bind=$CONSUL_BIND_ADDRESS"
echo "==> Found address '$CONSUL_BIND_ADDRESS' for interface '$CONSUL_BIND_INTERFACE', setting consul bind option..."
fi
CONSUL_CLIENT=
if [ -n "$CONSUL_CLIENT_INTERFACE" ]; then
CONSUL_CLIENT_ADDRESS=$(ip -o -4 addr list $CONSUL_CLIENT_INTERFACE | head -n1 | awk '{print $4}' | cut -d/ -f1)
if [ -z "$CONSUL_CLIENT_ADDRESS" ]; then
echo "Could not find IP for interface '$CONSUL_CLIENT_INTERFACE', exiting"
exit 1
fi
CONSUL_CLIENT="-client=$CONSUL_CLIENT_ADDRESS"
echo "==> Found address '$CONSUL_CLIENT_ADDRESS' for interface '$CONSUL_CLIENT_INTERFACE', settin consul client option..."
fi
CONSUL_BOOT=''
if [ "${consulboot}" = '1' ]; then
CONSUL_BOOT="-bootstrap -server"
fi
CONSUL_JOIN=
if [ -n "${consuljoinip}" ]; then
CONSUL_JOIN="-retry-join "${consuljoinip}""
fi
echo "${CONSUL_BOOT}"
echo "consul is starting"
nohup consul agent -datacenter=swiftdc ${CONSUL_BIND} ${CONSUL_CLIENT} -data-dir=${CONSUL_DATA_DIR} ${CONSUL_JOIN} ${CONSUL_BOOT} > /app/consul/log.txt 2>&1 &
sleep 15s
echo "consul has started"
cd /app/management/
nohup dotnet /app/management/Swift.Management.dll --urls "http://0.0.0.0:9632" 2> /app/swift/error.txt > /dev/null &
echo "management has started"
nohup dotnet /app/swift/Swift.dll -c ${cluster} 2> /app/swift/error.txt > /dev/null &
echo "swift has started"
# https://github.com/vearne/graceful_docker/blob/master/entrypoint.sh
while true; do echo hello world; sleep 3; done