Last active
August 29, 2015 14:01
-
-
Save rhoml/1c1165962a54cac0b44a to your computer and use it in GitHub Desktop.
Reconfigure script for sentinel to update twemproxy when certain redis instance fails.
This file contains hidden or 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
#!/bin/bash | |
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port> | |
export PATH=/sbin:/usr/local/bin:$PATH | |
NUTCRACKER_CONF='/opt/nutcracker/conf/nutcracker.yml' | |
NUTCRACKER_PORT=22121 | |
MASTER_NAME=$1 | |
ROLE=$2 | |
STATE=$3 | |
FROM_IP=$4 | |
FROM_PORT=$5 | |
TO_IP=$6 | |
TO_PORT=$7 | |
if [ "$#" = "7" ]; then | |
# Modify nutcracker.yml file | |
sed -i s/${FROM_IP}:${FROM_PORT}/${TO_IP}:${TO_PORT}/g ${NUTCRACKER_CONF} | |
# Pause traffic on nutcracker while we restart | |
iptables -I INPUT -p tcp --dport ${NUTCRACKER_PORT} --syn -j DROP | |
# Restart nutcracker | |
/etc/init.d/nutcracker restart | |
# Resume traffic after restarting | |
iptables -D INPUT -p tcp --dport ${NUTCRACKER_PORT} --syn -j DROP | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment