zoukankan      html  css  js  c++  java
  • redis 注册为服务

    进入redis的utils目录下,拷贝redis_init_script到/etc/init.d/下并重命名为redis

    修改redis,指定配置文件,我的redis配置文件为/etc/redis/redis.conf,之后chmod 777 redis,就可以执行service redis start/stop

    以下是redis_init_scrip文件

     1 #!/bin/sh
     2 #
     3 # Simple Redis init.d script conceived to work on Linux systems
     4 # as it does use of the /proc filesystem.
     5 
     6 ### BEGIN INIT INFO
     7 # Provides:     redis_6379
     8 # Default-Start:        2 3 4 5
     9 # Default-Stop:         0 1 6
    10 # Short-Description:    Redis data structure server
    11 # Description:          Redis data structure server. See https://redis.io
    12 ### END INIT INFO
    13 
    14 REDISPORT=6379
    15 EXEC=/usr/local/bin/redis-server
    16 CLIEXEC=/usr/local/bin/redis-cli
    17 
    18 PIDFILE=/var/run/redis_${REDISPORT}.pid
    19 #CONF="/etc/redis/${REDISPORT}.conf"
    20 CONF="/etc/redis/redis.conf"
    21 
    22 case "$1" in
    23     start)
    24         if [ -f $PIDFILE ]
    25         then
    26                 echo "$PIDFILE exists, process is already running or crashed"
    27         else
    28                 echo "Starting Redis server..."
    29                 $EXEC $CONF
    30         fi
    31         ;;
    32     stop)
    33         if [ ! -f $PIDFILE ]
    34         then
    35                 echo "$PIDFILE does not exist, process is not running"
    36         else
    37                 PID=$(cat $PIDFILE)
    38                 echo "Stopping ..."
    39                 $CLIEXEC -p $REDISPORT shutdown
    40                 while [ -x /proc/${PID} ]
    41                 do
    42                     echo "Waiting for Redis to shutdown ..."
    43                     sleep 1
    44                 done
    45                 echo "Redis stopped"
    46         fi
    47         ;;
    48     *)
    49         echo "Please use start or stop as first argument"
    50         ;;
    51 esac
  • 相关阅读:
    leetcode 912. 排序数组
    leetcode 633. 平方数之和
    leetcode 1512. 好数对的数目
    leetcode 1822. 数组元素积的符号
    leetcode 145. 二叉树的后序遍历
    leetcode 11. 盛最多水的容器
    leetcode 28 实现strStr()
    leetcode 27. 移除元素
    leetcode 26. 删除有序数组中的重复项
    产品化思维之公式系统
  • 原文地址:https://www.cnblogs.com/tele-share/p/10686114.html
Copyright © 2011-2022 走看看