From 0a838d925d54e191369aa2db9425b0badc0d0d45 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Wed, 4 Jan 2023 20:16:26 +0530 Subject: [PATCH] env variable can be set --- Dockerfile.sentinel | 2 +- entrypoint-sentinel.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Dockerfile.sentinel b/Dockerfile.sentinel index f4ff510..76959e4 100644 --- a/Dockerfile.sentinel +++ b/Dockerfile.sentinel @@ -40,7 +40,7 @@ RUN chown -R redis:redis /etc/redis VOLUME ["/sentinel-data"] -WORKDIR /data +WORKDIR /sentinel-data EXPOSE 26379 diff --git a/entrypoint-sentinel.sh b/entrypoint-sentinel.sh index 7455a8f..12e0584 100644 --- a/entrypoint-sentinel.sh +++ b/entrypoint-sentinel.sh @@ -1,6 +1,26 @@ #!/bin/bash +#Redis Configuration needed +PORT=${PORT:-6379} +IP=${IP:-0.0.0.0} +QUORUM=${QUORUM:-2} + +#Sentinel Config EXTERNAL_CONFIG_FILE=${EXTERNAL_CONFIG_FILE:-"/etc/redis/external.conf.d/redis-sentinel-additional.conf"} +DOWN_AFTER_MILLISECONDS=${DOWN_AFTER_MILLISECONDS:-30000} +PARALLEL_SYNCS=${PARALLEL_SYNCS:-1} +FAILOVER_TIMEOUT=${FAILOVER_TIMEOUT:-180000} + + +sentinel_mode_setup(){ + { + echo "sentinel monitor ${MASTER_GROUP_NAME} ${IP} ${PORT} ${QUORUM}" + echo "sentinel down-after-milliseconds ${MASTER_GROUP_NAME} ${DOWN_AFTER_MILLISECONDS}" + echo "sentinel parallel-syncs ${MASTER_GROUP_NAME} ${PARALLEL_SYNCS}" + echo "sentinel failover-timeout ${MASTER_GROUP_NAME} ${FAILOVER_TIMEOUT}" + }>> /etc/redis/sentinel.conf + +} external_config() { echo "include ${EXTERNAL_CONFIG_FILE}" >> /etc/redis/sentinel.conf @@ -15,6 +35,8 @@ start_sentinel() { main_function() { + sentinel_mode_setup + if [[ -f "${EXTERNAL_CONFIG_FILE}" ]]; then external_config fi -- 2.26.0