Blame SOURCES/redis-sentinel.init

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