Created
August 17, 2013 06:54
-
-
Save wingyiu/6255633 to your computer and use it in GitHub Desktop.
memcached init script for centos
This file contains 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: MemCached Daemon | |
# | |
# chkconfig: - 90 25 | |
# description: MemCached Daemon | |
# | |
### BEGIN INIT INFO | |
# Provides: memcached | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: memcached - Memory caching daemon | |
# Description: memcached - Memory caching daemon | |
### END INIT INFO | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
if [ -f /etc/sysconfig/memcached ];then | |
. /etc/sysconfig/memcached | |
fi | |
# Check that networking is up. | |
. /etc/sysconfig/network | |
if [ "$NETWORKING" = "no" ] | |
then | |
exit 0 | |
fi | |
PORT=11211 | |
USER=root | |
MAXCONN=1024 | |
CACHESIZE=64 | |
OPTIONS="" | |
MEMCACHED_HOME="/usr/local/memcached" | |
MEMCACHED="${MEMCACHED_HOME}/bin/memcached" | |
PIDFILE="/var/run/memcached.pid" | |
LOCKFILE="/var/lock/subsys/memcached" | |
RETVAL=0 | |
prog="memcached" | |
start () { | |
echo -n $"Starting $prog: " | |
# $MEMCACHED -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P $PIDFILE $OPTIONS | |
daemon --pidfile $PIDFILE $MEMCACHED -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P $PIDFILE $OPTIONS | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch $LOCKFILE | |
} | |
stop () { | |
echo -n $"Stopping $prog: " | |
# kill `cat ${PIDFILE}` | |
killproc -p $PIDFILE $MEMCACHED | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE $PIDFILE | |
} | |
restart () { | |
stop | |
start | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|reload) | |
restart | |
;; | |
status) | |
status memcached | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|reload}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment