-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #902 from camptocamp/test
Fix master, for Redis 6.2
- Loading branch information
Showing
4 changed files
with
38 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | ||
- DL3008 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,84 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SENTINEL_CONFIGURATION_FILE=/etc/sentinel.conf | ||
|
||
if [ "$AWS_IP_DISCOVERY" ]; then | ||
ANNOUNCE_IP=`curl http://169.254.169.254/latest/meta-data/local-ipv4` | ||
fi | ||
|
||
DEFAULT_REDIS_PORT=6379 | ||
: ${REDIS_PORT:=$DEFAULT_REDIS_PORT} | ||
: ${SENTINEL_PORT:=26379} | ||
: "${REDIS_PORT:=$DEFAULT_REDIS_PORT}" | ||
: "${SENTINEL_PORT:=26379}" | ||
|
||
# Backward compatibility fix previously existed DEFAULT_PORT | ||
if [ "$DEFAULT_PORT" ] && [ "$REDIS_PORT" -eq $DEFAULT_REDIS_PORT ]; then | ||
REDIS_PORT=$DEFAULT_PORT | ||
REDIS_PORT=$DEFAULT_PORT | ||
fi | ||
|
||
: ${QUORUM:=2} | ||
: ${DOWN_AFTER:=30000} | ||
: ${FAILOVER_TIMEOUT:=180000} | ||
: ${PARALLEL_SYNCS:=1} | ||
: "${QUORUM:=2}" | ||
: "${DOWN_AFTER:=30000}" | ||
: "${FAILOVER_TIMEOUT:=180000}" | ||
: "${PARALLEL_SYNCS:=1}" | ||
|
||
parse_addr () { | ||
parse_addr() { | ||
local _retvar=$1 | ||
IFS=':' read -ra ADDR <<< "$2" | ||
IFS=':' read -ra ADDR <<<"$2" | ||
|
||
if [ "${ADDR[1]}" = "" ]; then | ||
ADDR[1]=$REDIS_PORT | ||
fi | ||
|
||
eval $_retvar='("${ADDR[@]}")' | ||
eval "$_retvar"='("${ADDR[@]}")' | ||
} | ||
|
||
print_slave () { | ||
print_slave() { | ||
local -a ADDR | ||
parse_addr ADDR $1 | ||
echo "sentinel known-slave $MASTER_NAME ${ADDR[0]} ${ADDR[1]}" >> $SENTINEL_CONFIGURATION_FILE | ||
parse_addr ADDR "$1" | ||
echo "sentinel known-slave $MASTER_NAME ${ADDR[0]} ${ADDR[1]}" >>$SENTINEL_CONFIGURATION_FILE | ||
} | ||
|
||
print_master () { | ||
print_master() { | ||
local -a ADDR | ||
parse_addr ADDR $1 | ||
echo "sentinel monitor $MASTER_NAME ${ADDR[0]} ${ADDR[1]} $QUORUM" >> $SENTINEL_CONFIGURATION_FILE | ||
parse_addr ADDR "$1" | ||
echo "sentinel monitor $MASTER_NAME ${ADDR[0]} ${ADDR[1]} $QUORUM" >>$SENTINEL_CONFIGURATION_FILE | ||
} | ||
|
||
echo "port $SENTINEL_PORT" > $SENTINEL_CONFIGURATION_FILE | ||
echo "port $SENTINEL_PORT" >$SENTINEL_CONFIGURATION_FILE | ||
|
||
if [ "$ANNOUNCE_IP" ]; then | ||
echo "sentinel announce-ip $ANNOUNCE_IP" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel announce-ip $ANNOUNCE_IP" >>$SENTINEL_CONFIGURATION_FILE | ||
fi | ||
|
||
if [ "$ANNOUNCE_PORT" ]; then | ||
echo "sentinel announce-port $ANNOUNCE_PORT" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel announce-port $ANNOUNCE_PORT" >>$SENTINEL_CONFIGURATION_FILE | ||
fi | ||
|
||
if [ "$MASTER_NAME" ]; then | ||
print_master $MASTER | ||
echo "sentinel down-after-milliseconds $MASTER_NAME $DOWN_AFTER" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel failover-timeout $MASTER_NAME $FAILOVER_TIMEOUT" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel parallel-syncs $MASTER_NAME $PARALLEL_SYNCS" >> $SENTINEL_CONFIGURATION_FILE | ||
print_master "${MASTER}" | ||
{ | ||
echo "sentinel down-after-milliseconds $MASTER_NAME $DOWN_AFTER" | ||
echo "sentinel failover-timeout $MASTER_NAME $FAILOVER_TIMEOUT" | ||
echo "sentinel parallel-syncs $MASTER_NAME $PARALLEL_SYNCS" | ||
echo "sentinel resolve-hostnames yes" | ||
} >>$SENTINEL_CONFIGURATION_FILE | ||
|
||
if [ "$NOTIFICATION_SCRIPT" ]; then | ||
echo "sentinel notification-script $MASTER_NAME $NOTIFICATION_SCRIPT" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel notification-script $MASTER_NAME $NOTIFICATION_SCRIPT" >>$SENTINEL_CONFIGURATION_FILE | ||
fi | ||
|
||
if [ "$CLIENT_RECONFIG_SCRIPT" ]; then | ||
echo "sentinel client-reconfig-script $MASTER_NAME $CLIENT_RECONFIG_SCRIPT" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel client-reconfig-script $MASTER_NAME $CLIENT_RECONFIG_SCRIPT" >>$SENTINEL_CONFIGURATION_FILE | ||
fi | ||
|
||
if [ "$AUTH_PASS" ]; then | ||
echo "sentinel auth-pass $MASTER_NAME $AUTH_PASS" >> $SENTINEL_CONFIGURATION_FILE | ||
echo "sentinel auth-pass $MASTER_NAME $AUTH_PASS" >>$SENTINEL_CONFIGURATION_FILE | ||
fi | ||
|
||
if [ "$SLAVES" ]; then | ||
for SLAVE in $(echo $SLAVES | tr ";" "\n") | ||
do | ||
if [ "$SLAVE" ]; then | ||
print_slave $SLAVE | ||
if [ "${SLAVES}" ]; then | ||
for SLAVE in $(echo "${SLAVES}" | tr ";" "\n"); do | ||
if [ "${SLAVE}" ]; then | ||
print_slave "${SLAVE}" | ||
fi | ||
done | ||
fi | ||
fi | ||
|
||
cat $SENTINEL_CONFIGURATION_FILE | ||
exec redis-server $SENTINEL_CONFIGURATION_FILE --sentinel |