Blame SOURCES/redis.init

e5c076
#!/bin/sh
e5c076
#
e5c076
# redis        init file for starting up the redis daemon
e5c076
#
e5c076
# chkconfig:   - 20 80
e5c076
# description: Starts and stops the redis daemon.
e5c076
#
e5c076
### BEGIN INIT INFO
e5c076
# Provides: redis-server
e5c076
# Required-Start: $local_fs $remote_fs $network
e5c076
# Required-Stop: $local_fs $remote_fs $network
e5c076
# Short-Description: start and stop Redis 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-server"
e5c076
exec="/usr/bin/$name"
e5c076
shut="/usr/libexec/redis-shutdown"
e5c076
pidfile="/var/run/redis/redis.pid"
e5c076
REDIS_CONFIG="/etc/redis.conf"
e5c076
e5c076
[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis
e5c076
e5c076
lockfile=/var/lock/subsys/redis
e5c076
e5c076
start() {
e5c076
    [ -f $REDIS_CONFIG ] || exit 6
e5c076
    [ -x $exec ] || exit 5
e5c076
    echo -n $"Starting $name: "
e5c076
    daemon --user ${REDIS_USER-redis} "$exec $REDIS_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
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 $?