public
Created

CentOS /etc/init

  • Download Gist
memcached
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# pidfile: /var/run/memcached/memcached.pid
 
# Standard LSB functions
#. /lib/lsb/init-functions
 
# Source function library.
. /etc/init.d/functions
 
PORT=11211
USER=memcached
MAXCONN=1024
CACHESIZE=64
OPTIONS=""
 
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
 
RETVAL=0
prog="memcached"
 
start () {
echo -n $"Starting $prog: "
# insure that /var/run/memcached has proper permissions
if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
chown $USER /var/run/memcached
fi
 
daemon --pidfile /var/run/memcached/memcached.pid memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
}
stop () {
echo -n $"Stopping $prog: "
killproc -p /var/run/memcached/memcached.pid /usr/bin/memcached
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/memcached
rm -f /var/run/memcached.pid
fi
}
 
restart () {
stop
start
}
 
 
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status memcached
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/memcached ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
 
exit $?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.