-
Notifications
You must be signed in to change notification settings - Fork 0
/
Memcached-init-CentOS
106 lines (92 loc) · 2.13 KB
/
Memcached-init-CentOS
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/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
# Source function library.
. /etc/init.d/functions
PORT=11211
USER=memcached
MAXCONN=1024
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="/usr/local/memcached/bin/memcached"
start_instance() {
echo -n $"Starting $prog ($1): "
daemon --pidfile /var/run/memcached/memcached.$1.pid memcached -d -p $PORT -u $USER -m $2 -c $MAXCONN -P /var/run/memcached/memcached.$1.pid $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached.$1
PORT=`expr $PORT + 1`
}
stop_instance() {
echo -n $"Stopping $prog ($1): "
killproc -p /var/run/memcached/memcached.$1.pid /usr/bin/memcached
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/memcached.$1
rm -f /var/run/memcached.$1.pid
fi
}
start () {
# insure that /var/run/memcached has proper permissions
mkdir -p /var/run/memcached
if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
chown $USER /var/run/memcached
fi
start_instance default 64;
#start_instance block 16;
#start_instance content 128;
#start_instance filter 128;
#start_instance form 32;
#start_instance menu 16;
#start_instance page 8;
#start_instance update 8;
#start_instance views 8;
}
stop () {
stop_instance default;
#stop_instance block;
#stop_instance content;
#stop_instance filter;
#stop_instance form;
#stop_instance menu;
#stop_instance page;
#stop_instance update;
#stop_instance views;
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status memcached
;;
restart|reload|force-reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
exit 1
esac
exit $?