blob: 4d117a7a69c388c738fbf727a41fb00673fcf261 (
plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
|
#!/bin/sh
#
# cgred CGroups Rules Engine Daemon
# chkconfig: 2345 02 98
# description: This is a daemon for automatically classifying processes \
# into cgroups based on UID/GID.
#
# processname: cgrulesengd
# pidfile: /var/run/cgrulesengd.pid
#
# Source function library
. /etc/rc.d/init.d/functions
# Read in configuration options.
[ -f /etc/sysconfig/cgred ] && . /etc/sysconfig/cgred
start() {
if [ -f /var/lock/subsys/cgred ]; then
msg_already_running "CGroup Rules Engine Daemon"
return
fi
if [ ! -s /etc/cgrules.conf ]; then
nls "CGroup Rules Engine Daemon not configured"
RETVAL=6
return
fi
if ! grep -qs "^cgroup" /proc/mounts; then
nls "Cannot find cgroups, is cgconfig service running?"
RETVAL=1
return
fi
msg_starting "CGroup Rules Engine Daemon"
daemon --pidfile /var/run/cgrulesengd.pid /sbin/cgrulesengd $OPTIONS
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
return 7
fi
touch /var/lock/subsys/cgred
pidof cgrulesengd > /var/run/cgrulesengd.pid
}
stop() {
if [ ! -f /var/lock/subsys/cgred ]; then
msg_not_running "CGroup Rules Engine Daemon"
return
fi
msg_stopping "CGroup Rules Engine Daemon"
killproc --pidfile /var/run/cgrulesengd.pid cgrulesengd -TERM
RETVAL=$?
rm -f /var/lock/subsys/cgred /var/run/cgrulesengd.pid
}
reload() {
if [ ! -f /var/lock/subsys/cgred ] ; then
msg_not_running "CGroup Rules Engine Daemon"
return
fi
show "Reloading rules configuration..."
# SIGUSR2
kill -s 12 $(cat ${pidfile})
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
fail
else
ok
fi
}
condrestart() {
if [ ! -f /var/lock/subsys/cgred ]; then
msg_not_running "CGroup Rules Engine Daemon"
RETVAL=$1
return
fi
stop
start
}
RETVAL=0
# See how we are called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
try-restart)
condrestart 0
;;
force-reload)
condrestart 7
;;
status)
status --pidfile /var/run/cgrulesengd.pid cgrulesengd
RETVAL=$?
;;
*)
msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
exit 3
;;
esac
exit $RETVAL
|