Memcached Pool Bash Start Script
If you installed Memcached using Yum under the RedHat flavor of Linux, they have this really nice init.d scripts for starting and stopping Memcache. I modified it in order to support creating a bunch memcache instances using contiguous ports. What’s great is that only the “start” script has to be modified since the “stop” script uses a special RedHat function, killproc, which can accept a program name or path and kill all instances of that program. I’m still a noob at bash scripts but here is my only changes:
NUMBUCKETS=3 #only new value needed start() { for ((i=1;i<=$NUMBUCKETS;i+=1)); do FULLPORT=${PORT}${i} echo -n $"Starting $FULLPORT ($prog): \n" daemon $prog -d -p $FULLPORT -u $USER -c $MAXCONN -m $CACHESIZE $OPTIONS RETVAL=$? done echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL }