memcached/memcached.sysv

95 lines
1.7 KiB
Plaintext
Raw Normal View History

2007-07-10 20:00:32 +00:00
#! /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
2007-07-10 20:00:32 +00:00
# Standard LSB functions
#. /lib/lsb/init-functions
2007-07-10 20:00:32 +00:00
# Source function library.
. /etc/init.d/functions
PORT=11211
USER=memcached
2007-07-10 20:00:32 +00:00
MAXCONN=1024
CACHESIZE=64
OPTIONS=""
if [ -f /etc/sysconfig/memcached ];then
. /etc/sysconfig/memcached
fi
# Check that networking is up.
. /etc/sysconfig/network
2007-07-10 20:00:32 +00:00
if [ "$NETWORKING" = "no" ]
then
exit 0
fi
RETVAL=0
prog="memcached"
pidfile=${PIDFILE-/var/run/memcached/memcached.pid}
lockfile=${LOCKFILE-/var/lock/subsys/memcached}
2007-07-10 20:00:32 +00:00
start () {
echo -n $"Starting $prog: "
# Ensure that $pidfile directory has proper permissions and exists
piddir=`dirname $pidfile`
if [ ! -d $piddir ]; then
mkdir $piddir
fi
if [ "`stat -c %U $piddir`" != "$USER" ]; then
chown $USER $piddir
fi
2007-07-10 20:00:32 +00:00
daemon --pidfile ${pidfile} memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS
2007-07-10 20:00:32 +00:00
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
2007-07-10 20:00:32 +00:00
}
stop () {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} /usr/bin/memcached
2007-07-10 20:00:32 +00:00
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f ${lockfile} ${pidfile}
2007-07-10 20:00:32 +00:00
fi
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} memcached
RETVAL=$?
2007-07-10 20:00:32 +00:00
;;
restart|reload|force-reload)
restart
;;
condrestart|try-restart)
[ -f ${lockfile} ] && restart || :
2007-07-10 20:00:32 +00:00
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart}"
RETVAL=2
;;
2007-07-10 20:00:32 +00:00
esac
exit $RETVAL