#!/bin/sh # chkconfig: 2345 90 10 ### BEGIN INIT INFO # Provides: redis-server # Required-Start: $network $remote_fs $syslog $time # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start/stop redis-server ### END INIT INFO # # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. 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_$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) $0 stop $0 start ;; *) echo "Please use start, stop, restart or status as first argument" ;; esac
时间: 2024-10-08 06:39:27