#!/bin/sh # # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem.
### BEGIN INIT INFO # Provides: redis_6379 # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Redis data structure server # Description: Redis data structure server. See https://redis.io ### END INIT INFO
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 ..." if [ -n $REDISPWD ]; then $CLIEXEC -p $REDISPORT -a $REDISPWD shutdown else $CLIEXEC -p $REDISPORT shutdown fi 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
# 查看服务状态 ➜ systemctl status redis_6379 ● redis_6379.service - LSB: Redis data structure server Loaded: loaded (/etc/rc.d/init.d/redis_6379; bad; vendor preset: disabled) Active: active (running) since Mon 2019-11-11 02:21:03 UTC; 3s ago Docs: man:systemd-sysv-generator(8) Process: 1042 ExecStop=/etc/rc.d/init.d/redis_6379 stop (code=exited, status=0/SUCCESS) Process: 1056 ExecStart=/etc/rc.d/init.d/redis_6379 start (code=exited, status=0/SUCCESS) CGroup: /system.slice/redis_6379.service └─1058 /usr/local/redis/bin/redis-server 127.0.0.1:6379
Nov 11 02:21:03 cnetos7-localhost systemd[1]: Starting LSB: Redis data structure server... Nov 11 02:21:03 cnetos7-localhost redis_6379[1056]: Starting Redis server... Nov 11 02:21:03 cnetos7-localhost redis_6379[1056]: 1057:C 11 Nov 2019 02:21:03.594 # oO0OoO0OoO0Oo Re...0Oo Nov 11 02:21:03 cnetos7-localhost redis_6379[1056]: 1057:C 11 Nov 2019 02:21:03.594 # Redis version=5....ted Nov 11 02:21:03 cnetos7-localhost redis_6379[1056]: 1057:C 11 Nov 2019 02:21:03.594 # Configuration loaded Nov 11 02:21:03 cnetos7-localhost systemd[1]: Started LSB: Redis data structure server. Hint: Some lines were ellipsized, use -l to show in full.