-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
entrypoint.sh
27 lines (20 loc) · 797 Bytes
/
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
#!/bin/bash
set -e
DEFAULT="/usr/local/etc/haproxy/default_frontend.cfg"
BACKEND="/usr/local/etc/haproxy/backend.cfg"
# Update backend servers
cp /usr/local/etc/haproxy/backend.cfg.template $BACKEND
# shellcheck disable=SC2153
for COUCHDB_SERVER in ${COUCHDB_SERVERS//,/ }
do
echo " server $COUCHDB_SERVER $COUCHDB_SERVER:5984 check agent-check agent-inter 5s agent-addr $HEALTHCHECK_ADDR agent-port 5555" >> $BACKEND
done
# Place environment variables into config
envsubst < $DEFAULT
envsubst < $BACKEND
#Write pw for healthcheck subshell to work
mkdir -p /srv/storage/haproxy/passwd
echo "$COUCHDB_USER" > /srv/storage/haproxy/passwd/username
echo "$COUCHDB_PASSWORD" > /srv/storage/haproxy/passwd/admin
# Start haproxy
exec /usr/local/bin/docker-entrypoint.sh -f $DEFAULT -f $BACKEND