Skip to content

Commit

Permalink
Update docker-entrypoint.sh (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmrtvy authored and eli-darkly committed Nov 21, 2018
1 parent 885dd4f commit 1435de3
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ heartbeatIntervalSecs = ${HEARTBEAT_INTERVAL:-15}
" > /ldr/ld-relay.conf

if [ "$USE_REDIS" = 1 ]; then
if echo "$REDIS_PORT" | grep -q 'tcp://'; then
# REDIS_PORT gets set to tcp://$docker_ip:6379 when linking to a redis container
# default to using those values if they exist
REDIS_HOST_PART="${REDIS_PORT%:*}"
REDIS_HOST="${REDIS_HOST_PART##*/}"
REDIS_PORT="${REDIS_PORT##*:}"
fi
if [ -z "${REDIS_HOST}" ] && [ -z "${REDIS_URL}" ]; then echo "Choose REDIS_HOST and REDIS_PORT or REDIS_URL"; exit 1; fi

echo "
[redis]
host = \"${REDIS_HOST:-redis}\"
port = ${REDIS_PORT:-6379}
localTtl = ${REDIS_TTL:-30000}
" >> /ldr/ld-relay.conf
echo "[redis]" >> /ldr/ld-relay.conf

if [ -n "$REDIS_HOST" || -n "$REDIS_PORT" ]; then
if echo "$REDIS_PORT" | grep -q 'tcp://'; then
# REDIS_PORT gets set to tcp://$docker_ip:6379 when linking to a redis container
# default to using those values if they exist
REDIS_HOST_PART="${REDIS_PORT%:*}"
REDIS_HOST="${REDIS_HOST_PART##*/}"
REDIS_PORT="${REDIS_PORT##*:}"
fi
cat <<-EOF >> /ldr/ld-relay.conf
host = "${REDIS_HOST:-redis}"
port = "${REDIS_PORT:-6379}"
EOF
elif [ -n "${REDIS_URL+x}" ]; then
cat <<-EOF >> /ldr/ld-relay.conf
url = "${REDIS_URL}"
EOF
fi
echo "localTtl = ${REDIS_TTL:-30000}" >> /ldr/ld-relay.conf
fi
if [ "$USE_EVENTS" = 1 ]; then
Expand Down

0 comments on commit 1435de3

Please sign in to comment.