diff --git a/Dockerfile.sentinel b/Dockerfile.sentinel index f4ff51057163a5a381d5d6241039c8645e839969..76959e4fa834e1cb6585273c94bcd3b7addc98ff 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 7455a8f65caade2eae27fbacded4d6c733a12e49..12e0584da490f42769160e02f7960633019eecfa 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