Created
September 15, 2013 02:40
-
-
Save netkiller/6567585 to your computer and use it in GitHub Desktop.
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 | |
# memcached init file for memcached | |
# | |
# chkconfig: - 100 100 | |
# description: a distributed memory object caching system | |
# author: Neo Chen<[email protected]> | |
# | |
# processname: /usr/sbin/memcached | |
# config: | |
# pidfile: /var/run/memcached | |
# source function library | |
. /etc/init.d/functions | |
OPTIONS="-d -m 2048 -l 127.0.0.1 -p 11211 -u root -c 20000 -P /var/run/memcached" | |
RETVAL=0 | |
prog="memcached" | |
start() { | |
echo -n $"Starting $prog: " | |
if [ $UID -ne 0 ]; then | |
RETVAL=1 | |
failure | |
else | |
daemon /usr/sbin/memcached $OPTIONS | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached | |
fi; | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
if [ $UID -ne 0 ]; then | |
RETVAL=1 | |
failure | |
else | |
killproc /usr/sbin/memcached | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/memcached | |
fi; | |
echo | |
return $RETVAL | |
} | |
reload(){ | |
echo -n $"Reloading $prog: " | |
killproc /usr/sbin/memcached -HUP | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
restart(){ | |
stop | |
start | |
} | |
condrestart(){ | |
[ -e /var/lock/subsys/memcached ] && restart | |
return 0 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
# reload) | |
# reload | |
# ;; | |
condrestart) | |
condrestart | |
;; | |
status) | |
status memcached | |
RETVAL=$? | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|condrestart}" | |
RETVAL=1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment