2014-09-17 14:59:20 +02:00
|
|
|
#!/bin/bash
|
2014-09-11 21:40:02 +02:00
|
|
|
#
|
|
|
|
# Wrapper to close properly redis and sentinel
|
2014-09-17 14:59:20 +02:00
|
|
|
test x"$REDIS_DEBUG" != x && set -x
|
2014-09-11 21:40:02 +02:00
|
|
|
|
|
|
|
REDIS_CLI=/usr/bin/redis-cli
|
|
|
|
|
|
|
|
# Retrieve service name
|
2014-09-21 08:25:11 +02:00
|
|
|
SERVICE_NAME="$1"
|
2014-09-11 21:40:02 +02: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 23:59:51 +01:00
|
|
|
# Use awk to retrieve host, port from config file
|
|
|
|
HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE`
|
2014-09-11 21:40:02 +02:00
|
|
|
PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE`
|
|
|
|
|
2015-03-26 23:59:51 +01:00
|
|
|
# Just in case, use default host, port
|
|
|
|
HOST=${HOST:-127.0.0.1}
|
2014-09-11 21:40:02 +02:00
|
|
|
if [ "$SERVICE_NAME" = redis ]; then
|
2014-09-13 15:05:11 +02:00
|
|
|
PORT=${PORT:-6379}
|
2014-09-11 21:40:02 +02:00
|
|
|
else
|
|
|
|
PORT=${PORT:-26739}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shutdown the service properly
|
2015-03-26 23:59:51 +01:00
|
|
|
$REDIS_CLI -h $HOST -p $PORT shutdown
|