#!/bin/bash
#
# chkconfig: 2345 90 60
# description: nginx
# processname: nginx
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
MEMCACHED_SBIN="/usr/local/memcached/bin/memcached"
MEMCACHED_CONF=" -d -m 32 -u root -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid &"
MEMCACHED_PID="/tmp/memcached.pid"
#全局返回值
RETVAL=0
#进程提示名称
prog="memcached"
start() {
echo -n $"Starting $prog: "
#启动一个进程 daemon是个函数,定义在functions
daemon $MEMCACHED_SBIN $MEMCACHED_CONF
RETVAL=$?
# 输出换行符
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $MEMCACHED_PID $MEMCACHED_SBIN -TERM
RETVAL=$?
rm -rf $MEMCACHED_PID
echo
return $RETVAL
}
reload(){
echo -n $"Reloading $prog: "
killproc -p $MEMCACHED_PID $MEMCACHED_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|reload|restart}"
RETVAL=1
esac
exit $RETVAL
转载于:https://my.oschina.net/web256/blog/544494