3 # cgred CGroups Rules Engine Daemon
4 # chkconfig: 2345 02 98
5 # description: This is a daemon for automatically classifying processes \
6 # into cgroups based on UID/GID.
8 # processname: cgrulesengd
9 # pidfile: /var/run/cgrulesengd.pid
12 # Source function library
13 . /etc/rc.d/init.d/functions
16 if [ -f /var/lock/subsys/cgred ]; then
17 msg_already_running "CGroup Rules Engine Daemon"
21 if [ ! -s /etc/cgrules.conf ]; then
22 nls "CGroup Rules Engine Daemon not configured"
26 if ! grep -qs "^cgroup" /proc/mounts; then
27 nls "Cannot find cgroups, is cgconfig service running?"
32 msg_starting "CGroup Rules Engine Daemon"
33 # Read in configuration options.
35 if [ -f /etc/sysconfig/cgred.conf ]; then
36 . /etc/sysconfig/cgred.conf
38 OPTIONS="$NODAEMON $LOG"
39 [ -n "$LOG_FILE" ] && OPTIONS="$OPTIONS --logfile=$LOG_FILE"
40 [ -n "$SOCKET_USER" ] && OPTIONS="$OPTIONS -u $SOCKET_USER"
41 [ -n "$SOCKET_GROUP" ] && OPTIONS="$OPTIONS -g $SOCKET_GROUP"
44 daemon --pidfile /var/run/cgrulesengd.pid /sbin/cgrulesengd $OPTIONS
46 if [ $RETVAL -ne 0 ]; then
49 touch /var/lock/subsys/cgred
50 pidof cgrulesengd > /var/run/cgrulesengd.pid
54 if [ ! -f /var/lock/subsys/cgred ]; then
55 msg_not_running "CGroup Rules Engine Daemon"
59 msg_stopping "CGroup Rules Engine Daemon"
60 killproc --pidfile /var/run/cgrulesengd.pid cgrulesengd -TERM
62 rm -f /var/lock/subsys/cgred /var/run/cgrulesengd.pid
66 if [ ! -f /var/lock/subsys/cgred ] ; then
67 msg_not_running "CGroup Rules Engine Daemon"
71 show "Reloading rules configuration..."
73 kill -s 12 $(cat ${pidfile})
75 if [ $RETVAL -eq 0 ]; then
83 if [ ! -f /var/lock/subsys/cgred ]; then
84 msg_not_running "CGroup Rules Engine Daemon"
94 # See how we are called
116 status --pidfile /var/run/cgrulesengd.pid cgrulesengd
120 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"