rediscentospidmonitrhel6

Redis Daemon not creating a PID file


The Redis startup script is supposed to create a pid file at startup, but I've confirmed all the settings I can find, and no pid file is ever created.

I installed redis by:

$ yum install redis
$ chkconfig redis on
$ service redis start

In my config file (/etc/redis.conf) I checked to make sure these were enabled:

daemonize yes
pidfile /var/run/redis/redis.pid

And in the startup script (/etc/init.d/redis) there is:

exec="/usr/sbin/$name"
pidfile="/var/run/redis/redis.pid"
REDIS_CONFIG="/etc/redis.conf"

[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis

lockfile=/var/lock/subsys/redis

start() {
    [ -f $REDIS_CONFIG ] || exit 6
    [ -x $exec ] || exit 5
    echo -n $"Starting $name: "
    daemon --user ${REDIS_USER-redis} "$exec $REDIS_CONFIG"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $name: "
    killproc -p $pidfile $name
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

These are the settings that came by default with the install. Any idea why no pid file is created? I need to use it for Monit. (The system is RHEL 6.4 btw)


Solution

  • Problem was that the user redis did not have permission to create the pid file (or directory it was in). Fix:

    sudo mkdir /var/run/redis
    sudo chown redis /var/run/redis
    

    Then I killed and restarted redis and sure enough, there was redis.pid