Skip to content

Commit

Permalink
Support custom sentinel port (#64)
Browse files Browse the repository at this point in the history
Signed-off-by: drivebyer <[email protected]>
  • Loading branch information
drivebyer authored Dec 18, 2023
1 parent 6db8e2e commit 4d01a33
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ FROM alpine:3.15

ARG TARGETARCH

ENV SENTINEL_PORT=26379

LABEL version=1.0 \
arch=$TARGETARCH \
description="A production grade performance tuned redis docker image created by Opstree Solutions"
Expand Down Expand Up @@ -50,7 +52,7 @@ VOLUME ["/sentinel-data"]

WORKDIR /sentinel-data

EXPOSE 26379
EXPOSE ${SENTINEL_PORT}

USER 1000

Expand Down
7 changes: 7 additions & 0 deletions entrypoint-sentinel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ acl_setup(){
fi
}

port_setup() {
{
echo port "${SENTINEL_PORT}"
} >> /etc/redis/sentinel.conf
}

start_sentinel() {
echo "Starting sentinel service ....."
exec redis-sentinel /etc/redis/sentinel.conf
Expand All @@ -84,6 +90,7 @@ main_function() {
sentinel_mode_setup
tls_setup
acl_setup
port_setup
if [[ -f "${EXTERNAL_CONFIG_FILE}" ]]; then
external_config
fi
Expand Down
4 changes: 2 additions & 2 deletions healthcheck-Sentinel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ check_redis_health() {
export REDISCLI_AUTH="${REDIS_PASSWORD}"
fi
if [[ "${TLS_MODE}" == "true" ]]; then
redis-cli --tls --cert "${REDIS_TLS_CERT}" --key "${REDIS_TLS_CERT_KEY}" --cacert "${REDIS_TLS_CA_KEY}" -h "$(hostname)" -p 26379 ping
redis-cli --tls --cert "${REDIS_TLS_CERT}" --key "${REDIS_TLS_CERT_KEY}" --cacert "${REDIS_TLS_CA_KEY}" -h "$(hostname)" -p "${SENTINEL_PORT}" ping
else
redis-cli -h "$(hostname)" -p 26379 ping
redis-cli -h "$(hostname)" -p "${SENTINEL_PORT}" ping
fi
}

Expand Down
1 change: 0 additions & 1 deletion sentinel.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
port 26379
daemonize no
pidfile /var/run/redis-sentinel.pid
logfile ""
Expand Down

0 comments on commit 4d01a33

Please sign in to comment.