I also encountered the same problem. My situation at the time was: using puppet for automatic delivery and deployment of redis, after enabling the authentication password for redis, and closing the service in puppet, puppet would freeze and cannot continue. Later, the same thing was discovered when manually locating the problem. The reason is actually that the service control script provided by the redis author in the source code package does not consider how to shut down the service after adding the authentication password. The shutdown method with password is: redis-cli -p port-a password shutdown Because I use puppet to deploy redis, I made this script into a puppet file template. If a password is added, the service control will be automatically modified. script. I've posted the template, hope it helps.
#!/bin/sh
#Configurations injected by install_server below....
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_<%= name %>.pid
CONF="/etc/redis/<%= name %>.conf"
REDISPORT="<%= name %>"
###############
# SysV Init Information
# chkconfig: - 58 74
# description: redis_<%= name %> is the redis daemon.
### BEGIN INIT INFO
# Provides: redis_<%= name %>
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: $syslog $named
# Should-Stop: $syslog $named
# Short-Description: start and stop redis_<%= name %>
# Description: Redis daemon
### END INIT INFO
case "" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis_$REDISPORT server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
<% if @password == 'nopass' -%>
$CLIEXEC -p $REDISPORT shutdown
<% else -%>
$CLIEXEC -p $REDISPORT -a <%= @password %> shutdown
<% end -%>
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis_$REDISPORT to shutdown ..."
sleep 2
done
echo "Redis_$REDISPORT stopped"
fi
;;
status)
PID=$(cat $PIDFILE)
if [ -f $PIDFILE ]
then
if [ ! -x /proc/${PID} ]
then
echo 'Redis_$REDISPORT is not running'
rm -rf $PIDFILE
exit 1
else
echo "Redis_$REDISPORT is running"
fi
else
echo 'No PID File,Redis_$REDISPORT is not running'
exit 1
fi
;;
restart)
rrreee stop
rrreee start
;;
*)
echo "Please use start, stop, restart or status as first argument"
;;
esac
Currently, I have temporarily made a script to shut down Redis, and run it manually before shutting down the virtual machine. A little rubbing.
Because Shell programming is not familiar, you still need to learn your script. However, if redis-cli does not have a key, it should return a NOAUTH error. You need to make a judgment after capturing it and reuse redis-cli+key to close Redis.
Finally, look for the corresponding shutdown script in the /etc/init directory to see how to integrate it.
I also encountered the same problem.
My situation at the time was: using puppet for automatic delivery and deployment of redis, after enabling the authentication password for redis, and closing the service in puppet, puppet would freeze and cannot continue. Later, the same thing was discovered when manually locating the problem.
The reason is actually that the service control script provided by the redis author in the source code package does not consider how to shut down the service after adding the authentication password.
The shutdown method with password is: redis-cli -p port-a password shutdown
Because I use puppet to deploy redis, I made this script into a puppet file template. If a password is added, the service control will be automatically modified. script. I've posted the template, hope it helps.
Redis
可以通过客户端执行SHUTDOWN
command to close.Currently, I have temporarily made a script to shut down Redis, and run it manually before shutting down the virtual machine. A little rubbing.
Because Shell programming is not familiar, you still need to learn your script. However, if redis-cli does not have a key, it should return a NOAUTH error. You need to make a judgment after capturing it and reuse redis-cli+key to close Redis.
Finally, look for the corresponding shutdown script in the /etc/init directory to see how to integrate it.