summaryrefslogtreecommitdiffstats
path: root/redis-shutdown
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-09-12 18:09:08 +0200
committerRemi Collet <fedora@famillecollet.com>2014-09-12 18:09:08 +0200
commit912b891ca07160a56924e91db92e8b4d40aa1175 (patch)
tree6926b3a08869aede23d8577f9a899a76b4909129 /redis-shutdown
parent5d9fa3923a03b577eca13ba60fb95b36d9e5df72 (diff)
redis: 2.8.15
Diffstat (limited to 'redis-shutdown')
-rw-r--r--redis-shutdown28
1 files changed, 28 insertions, 0 deletions
diff --git a/redis-shutdown b/redis-shutdown
new file mode 100644
index 0000000..1bf0e16
--- /dev/null
+++ b/redis-shutdown
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Wrapper to close properly redis and sentinel
+test x"REDIS_DEBUG" != x && set -x
+
+REDIS_CLI=/usr/bin/redis-cli
+
+# Retrieve service name
+SERVICE_NAME="$2"
+if [ -z "$SERVICE_NAME" ]; then
+ SERVICE_NAME=redis
+fi
+
+# Get the proper config file based on service name
+CONFIG_FILE="/etc/$SERVICE_NAME.conf"
+
+# Use awk to retrieve port from config file
+PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE`
+
+# Just in case, use default port
+if [ "$SERVICE_NAME" = redis ]; then
+ PORT=${PORT:-6379}
+else
+ PORT=${PORT:-26739}
+fi
+
+# shutdown the service properly
+$REDIS_CLI -p $PORT shutdown \ No newline at end of file