-
-
Save skyriser/6e311fc194d8aac62d0a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: redis sentinel | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Starts redis sentinel | |
# Description: Starts redis sentinel using start-stop-daemon | |
### END INIT INFO | |
NAME=redis-sentinel | |
BIN=/usr/local/bin/redis-server | |
SENTINEL_PID=/tmp/redis-sentinel.pid | |
CMD=$1 | |
start() { | |
echo "Starting $NAME ..." | |
exec 2>&1 $BIN /etc/redis/sentinel.conf --sentinel | logger -t sentinel & | |
echo $! > "${SENTINEL_PID}"; | |
} | |
stop() { | |
PID=`cat $SENTINEL_PID` | |
echo "Stopping $NAME ($PID) ..." | |
kill $PID | |
} | |
restart() { | |
echo "Restarting $NAME ..." | |
stop | |
start | |
} | |
case "$CMD" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage $0 {start|stop|restart}" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment