Blame SOURCES/redis-sentinel.init

6bfd36
#!/bin/sh
6bfd36
#
6bfd36
# redis        init file for starting up the redis-sentinel daemon
6bfd36
#
6bfd36
# chkconfig:   - 21 79
6bfd36
# description: Starts and stops the redis-sentinel daemon.
6bfd36
#
6bfd36
### BEGIN INIT INFO
6bfd36
# Provides: redis-sentinel
6bfd36
# Required-Start: $local_fs $remote_fs $network
6bfd36
# Required-Stop: $local_fs $remote_fs $network
6bfd36
# Short-Description: start and stop Sentinel server
6bfd36
# Description: A persistent key-value database
6bfd36
### END INIT INFO
6bfd36
6bfd36
# Source function library.
6bfd36
. /etc/rc.d/init.d/functions
6bfd36
6bfd36
name="redis-sentinel"
6bfd36
exec="/usr/bin/$name"
6bfd36
shut="/usr/libexec/redis-shutdown"
6bfd36
pidfile="/var/run/redis/sentinel.pid"
6bfd36
SENTINEL_CONFIG="/etc/redis-sentinel.conf"
6bfd36
6bfd36
[ -e /etc/sysconfig/redis-sentinel ] && . /etc/sysconfig/redis-sentinel
6bfd36
6bfd36
lockfile=/var/lock/subsys/redis
6bfd36
6bfd36
start() {
6bfd36
    [ -f $SENTINEL_CONFIG ] || exit 6
6bfd36
    [ -x $exec ] || exit 5
6bfd36
    echo -n $"Starting $name: "
6bfd36
    daemon --user ${REDIS_USER-redis} "$exec $SENTINEL_CONFIG --daemonize yes --pidfile $pidfile"
6bfd36
    retval=$?
6bfd36
    echo
6bfd36
    [ $retval -eq 0 ] && touch $lockfile
6bfd36
    return $retval
6bfd36
}
6bfd36
6bfd36
stop() {
6bfd36
    echo -n $"Stopping $name: "
6bfd36
    [ -x $shut ] && $shut $name
6bfd36
    retval=$?
6bfd36
    if [ -f $pidfile ]
6bfd36
    then
6bfd36
        # shutdown haven't work, try old way
6bfd36
        killproc -p $pidfile $name
6bfd36
        retval=$?
6bfd36
    else
6bfd36
        success "$name shutdown"
6bfd36
    fi
6bfd36
    echo
6bfd36
    [ $retval -eq 0 ] && rm -f $lockfile
6bfd36
    return $retval
6bfd36
}
6bfd36
6bfd36
restart() {
6bfd36
    stop
6bfd36
    start
6bfd36
}
6bfd36
6bfd36
rh_status() {
6bfd36
    status -p $pidfile $name
6bfd36
}
6bfd36
6bfd36
rh_status_q() {
6bfd36
    rh_status >/dev/null 2>&1
6bfd36
}
6bfd36
6bfd36
6bfd36
case "$1" in
6bfd36
    start)
6bfd36
        rh_status_q && exit 0
6bfd36
        $1
6bfd36
        ;;
6bfd36
    stop)
6bfd36
        rh_status_q || exit 0
6bfd36
        $1
6bfd36
        ;;
6bfd36
    restart)
6bfd36
        $1
6bfd36
        ;;
6bfd36
    status)
6bfd36
        rh_status
6bfd36
        ;;
6bfd36
    condrestart|try-restart)
6bfd36
        rh_status_q || exit 0
6bfd36
        restart
6bfd36
        ;;
6bfd36
    *)
6bfd36
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
6bfd36
        exit 2
6bfd36
esac
6bfd36
exit $?