2014-09-17 12:59:20 +00:00
|
|
|
#!/bin/bash
|
2014-09-11 19:40:02 +00:00
|
|
|
#
|
|
|
|
# Wrapper to close properly redis and sentinel
|
2014-09-17 12:59:20 +00:00
|
|
|
test x"$REDIS_DEBUG" != x && set -x
|
2014-09-11 19:40:02 +00:00
|
|
|
|
|
|
|
REDIS_CLI=/usr/bin/redis-cli
|
|
|
|
|
|
|
|
# Retrieve service name
|
2014-09-21 06:25:11 +00:00
|
|
|
SERVICE_NAME="$1"
|
2014-09-11 19:40:02 +00:00
|
|
|
if [ -z "$SERVICE_NAME" ]; then
|
|
|
|
SERVICE_NAME=redis
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get the proper config file based on service name
|
|
|
|
CONFIG_FILE="/etc/$SERVICE_NAME.conf"
|
|
|
|
|
2015-03-26 22:59:51 +00:00
|
|
|
# Use awk to retrieve host, port from config file
|
|
|
|
HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE`
|
2014-09-11 19:40:02 +00:00
|
|
|
PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE`
|
|
|
|
|
2015-03-26 22:59:51 +00:00
|
|
|
# Just in case, use default host, port
|
|
|
|
HOST=${HOST:-127.0.0.1}
|
2014-09-11 19:40:02 +00:00
|
|
|
if [ "$SERVICE_NAME" = redis ]; then
|
2014-09-13 13:05:11 +00:00
|
|
|
PORT=${PORT:-6379}
|
2014-09-11 19:40:02 +00:00
|
|
|
else
|
|
|
|
PORT=${PORT:-26739}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shutdown the service properly
|
2015-03-26 22:59:51 +00:00
|
|
|
$REDIS_CLI -h $HOST -p $PORT shutdown
|