Skip to content

Instantly share code, notes, and snippets.

@mathieue
Created February 4, 2013 16:19
Show Gist options
  • Save mathieue/4707757 to your computer and use it in GitHub Desktop.
Save mathieue/4707757 to your computer and use it in GitHub Desktop.
redis sentinel startup script
#!/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
@daverstam
Copy link

Same issue as @ethergreg, I used this instead:

echo $(pidof redis-sentinel) > $SENTINEL_PID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment