#!/bin/bash #======================================================================================= # chkconfig: 2345 08 92 # description: Distributed memory caching daemon # processname: memcached #======================================================================================= #IPADDR=`/sbin/ifconfig eth0 | awk -F ':' '/inet addr/{print $2}' | sed 's/[a-zA-Z ]//g'` #IPADDR=127.0.0.1 PORT="11211" USER="root" SIZE="256" CONNNUM="100" PIDFILE="/var/run/memcached.pid" BINFILE="/usr/local/bin/memcached" LOCKFILE="/var/lock/subsys/memcached" RETVAL=0 source /etc/init.d/functions start() { echo -n $"Starting memcached......" daemon $BINFILE -d -p $PORT -u $USER -m $SIZE -c $CONNNUM -P $PIDFILE RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCKFILE return $RETVAL } stop() { echo -n $"Shutting down memcached......" killproc $BINFILE RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $LOCKFILE return $RETVAL } restart() { stop sleep 1 start } reload() { echo -n $"Reloading memcached......" killproc $BINFILE -HUP RETVAL=$? echo return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e $LOCKFILE ] && restart RETVAL=$? ;; reload) reload ;; status) status $prog RETVAL=$? ;; *) echo "Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL