-
Notifications
You must be signed in to change notification settings - Fork 5
/
entrypoint.sh
115 lines (106 loc) · 3.83 KB
/
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
set -e
_preflight() {
echo 'Codecov preflight started.'
COUNTER=0
echo 'Waiting for Codecov Default to start ...'
while [ -z "`nc -vz $CODECOV_DEFAULT_HOST $CODECOV_DEFAULT_PORT 2>&1 | grep open`" ]; do
COUNTER=$(($COUNTER+1))
if [ "$COUNTER" -gt 30 ]; then
echo "Timeout waiting for Codecov Default to start"
echo "Review documentation: https://docs.codecov.io/docs/configuration"
exit 1
elif [ "$COUNTER" -eq 15 ]; then
echo 'Still waiting for Codecov Default to start ...'
fi
sleep 1
done
echo 'Codecov Default started.'
if [ "$CODECOV_GATEWAY_PROXY_MODE_ENABLED" ]; then
return 0
fi
COUNTER=0
echo 'Waiting for Codecov api to start ...'
while [ -z "`nc -vz $CODECOV_API_HOST $CODECOV_API_PORT 2>&1 | grep open`" ]; do
COUNTER=$(($COUNTER+1))
if [ "$COUNTER" -gt 60 ]; then
echo "Timeout waiting for Codecov api to start"
echo "If this is the first boot ever, initial migrations may have taken longer than this timer. Please restart this service (gateway)"
echo "Check logs on api and ensure proper configuration: https://docs.codecov.io/changelog/release-notes-for-v500#infrastructure for more information"
exit 1
elif [ "$COUNTER" -eq 30 ]; then
echo 'Still waiting for Codecov api to start ...'
fi
sleep 1
done
echo 'Codecov api started.'
COUNTER=0
echo 'Waiting for Codecov ia to start ...'
while [ -z "`nc -vz $CODECOV_IA_HOST $CODECOV_IA_PORT 2>&1 | grep open`" ]; do
COUNTER=$(($COUNTER+1))
if [ "$COUNTER" -gt 30 ]; then
echo "Timeout waiting for Codecov IA to start"
echo "Check logs on IA and ensure proper configuration: https://docs.codecov.io/changelog/release-notes-for-v500#infrastructure for more information"
exit 1
elif [ "$COUNTER" -eq 15 ]; then
echo 'Still waiting for Codecov IA to start ...'
fi
sleep 1
done
echo 'Codecov IA started.'
echo 'Codecov preflight complete.'
}
_start_haproxy() {
export DOLLAR='$'
BACKENDS="-f /etc/haproxy/1-backends.conf"
routing_map="codecov"
if [ "$CODECOV_GATEWAY_PROXY_MODE_ENABLED" ]; then
BACKENDS=""
routing_map="proxy"
fi
export CODECOV_GATEWAY_ROUTING_MAP=${routing_map}
if [ "$CODECOV_GATEWAY_SSL_ENABLED" ]; then
echo 'Codecov gateway ssl enabled'
envsubst < /etc/haproxy/3-ssl.conf.template > /etc/haproxy/2-frontends.conf
else
echo 'Codecov gateway ssl disabled'
envsubst < /etc/haproxy/2-http.conf.template > /etc/haproxy/2-frontends.conf
fi
ssl_string="ssl verify none "
if [ $CODECOV_DEFAULT_SCHEME = "https" ]; then
export CODECOV_DEFAULT_SSL_FLAG=$ssl_string
fi
if [ $CODECOV_API_SCHEME = "https" ]; then
export CODECOV_API_SSL_FLAG=$ssl_string
fi
if [ $CODECOV_IA_SCHEME = "https" ]; then
export CODECOV_IA_SSL_FLAG=$ssl_string
fi
if [ "$CODECOV_GATEWAY_CHROOT_DISABLED" ]; then
echo 'Codecov gateway chroot disabled'
envsubst < /etc/haproxy/0-haproxy-no-chroot.conf.template > /etc/haproxy/0-haproxy.conf
else
envsubst < /etc/haproxy/0-haproxy.conf.template > /etc/haproxy/0-haproxy.conf
fi
BACKENDS="-f /etc/haproxy/1-backends.conf"
envsubst < /etc/haproxy/1-backends.conf.template > /etc/haproxy/1-backends.conf
MINIO_FILE=""
if [ "$CODECOV_GATEWAY_MINIO_ENABLED" ]; then
echo 'Codecov gateway minio enabled'
if [ $CODECOV_MINIO_SCHEME = "https" ]; then
export CODECOV_MINIO_SSL_FLAG=$ssl_string
fi
envsubst < /etc/haproxy/1-minio.conf.template > /etc/haproxy/1-minio.conf
cat /etc/haproxy/minio.map >> /etc/haproxy/routing.map
MINIO_FILE="-f /etc/haproxy/1-minio.conf"
fi
echo "Starting haproxy"
haproxy -W -db -f /etc/haproxy/0-haproxy.conf $BACKENDS $MINIO_FILE -f /etc/haproxy/2-frontends.conf
}
if [ -z "$1" ];
then
_preflight
_start_haproxy
else
exec "$@"
fi