Created
July 26, 2013 09:19
-
-
Save sunfuze/6087494 to your computer and use it in GitHub Desktop.
将redis加入到service中
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# redis Startup script for redis processes | |
# | |
# author: snowolf | |
# | |
# processname: redis | |
redis_path="/usr/local/bin/redis-server" | |
redis_conf="/etc/redis/redis.conf" | |
redis_pid="/var/run/redis.pid" | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
[ -x $redis_path ] || exit 0 | |
RETVAL=0 | |
prog="redis" | |
# Start daemons. | |
start() { | |
if [ -e $redis_pid -a ! -z $redis_pid ];then | |
echo $prog" already running...." | |
exit 1 | |
fi | |
echo -n $"Starting $prog " | |
# Single instance for all caches | |
$redis_path $redis_conf | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && { | |
touch /var/lock/subsys/$prog | |
success $"$prog" | |
} | |
echo | |
return $RETVAL | |
} | |
# Stop daemons. | |
stop() { | |
echo -n $"Stopping $prog " | |
killproc -d 10 $redis_path | |
echo | |
[ $RETVAL = 0 ] && rm -f $redis_pid /var/lock/subsys/$prog | |
RETVAL=$? | |
return $RETVAL | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status $prog | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
condrestart) | |
if test "x`pidof redis`" != x; then | |
stop | |
start | |
fi | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|condrestart}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment