Skip to content

Commit

Permalink
Add the ability to connect to redis cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
VyacheslavSemin committed Jan 25, 2024
1 parent 6173cff commit f171053
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ case $AMQP_PROTO in
;;
esac

if [[ -n "$REDIS_CLUSTER_NODES" ]]; then
declare -a REDIS_CLUSTER_NODES_ALL=($REDIS_CLUSTER_NODES)
REDIS_CLUSTER_NODES_ARRAY=()
for node in "${REDIS_CLUSTER_NODES_ALL[@]}"; do
REDIS_CLUSTER_NODES_ARRAY+=('{ "url": "redis://'$node'" }')
done
OLD_IFS="$IFS"
IFS=", "
NODES=$(echo "${REDIS_CLUSTER_NODES_ARRAY[*]}")
IFS="$OLD_IFS"
REDIS_CLUSTER='"rootNodes": [ '$NODES' ], "defaults": { "username": "'${REDIS_SERVER_USER:-default}'", "password": "'$REDIS_SERVER_PWD'" }'
else
CLUSTER=''
fi

export NODE_CONFIG='{
"statsd": {
"useMetrics": '${METRICS_ENABLED:-false}',
Expand All @@ -49,6 +64,7 @@ export NODE_CONFIG='{
"password": "'${REDIS_SERVER_PWD}'",
"db": "'${REDIS_SERVER_DB_NUM:-0}'"
},
"optionsCluster": { '${REDIS_CLUSTER}' },
"iooptions": {
"sentinels": [
{
Expand Down

0 comments on commit f171053

Please sign in to comment.