我正在按照在生产机器上安装 Redis 的说明进行操作(使用 chkconfig 的 CentOS)。
给我的示例脚本需要start
实际启动它的参数,这似乎 init.d 不这样做(传递参数)。
必须运行的真正命令是/etc/init.d/redis_6379 start
,但它实际调用的是什么/etc/inti.d/redis_6379
,它只是说use start or stop as an argument
因此,当我的服务器重新启动时,它实际上并没有启动 redis。我应该在这里做什么?
这是初始配置
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis_6379
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac