3
# Start/Stop the CGroups Rules Engine Daemon
5
# Copyright Red Hat Inc. 2008
7
# Authors: Steve Olivieri <sjo@redhat.com>
8
# This program is free software; you can redistribute it and/or modify it
9
# under the terms of version 2.1 of the GNU Lesser General Public License
10
# as published by the Free Software Foundation.
12
# This program is distributed in the hope that it would be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
# cgred CGroups Rules Engine Daemon
18
# description: This is a daemon for automatically classifying processes \
19
# into cgroups based on UID/GID.
21
# processname: cgrulesengd
22
# pidfile: /var/run/cgred.pid
25
# Provides: cgrulesengd
26
# Required-Start: $local_fs $syslog $cgconfig
27
# Required-Stop: $local_fs $syslog
30
# Short-Description: start and stop the cgroups rules engine daemon
31
# Description: CGroup Rules Engine is a tool for automatically using \
32
# cgroups to classify processes
35
prefix=@prefix@;exec_prefix=@exec_prefix@;sbindir=@sbindir@
36
CGRED_BIN=$sbindir/cgrulesengd
39
[ -x $CGRED_BIN ] || exit 1
41
# Source function library & LSB routines
42
. /etc/rc.d/init.d/functions
43
. /lib/lsb/init-functions
45
# Read in configuration options.
46
if [ -f "/etc/sysconfig/cgred.conf" ] ; then
47
. /etc/sysconfig/cgred.conf
48
OPTIONS="$NODAEMON $LOG"
49
if [ -n "$LOG_FILE" ]; then
50
OPTIONS="$OPTIONS --log-file=$LOG_FILE"
57
processname=cgrulesengd
59
pidfile=/var/run/cgred.pid
65
echo $"Starting CGroup Rules Engine Daemon..."
66
if [ -f "/var/lock/subsys/$servicename" ] ; then
67
log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
70
daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
73
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
74
echo "`pidof $processname`" > $pidfile
79
echo -n $"Stopping CGroup Rules Engine Daemon..."
80
killproc -p $pidfile $processname -TERM
83
if [ $RETVAL -eq 0 ] ; then
84
rm -f /var/lock/subsys/$servicename
90
# See how we are called
99
status -p $pidfile $processname
107
if [ -f /var/lock/subsys/$servicename ] ; then
113
if [ -f /var/lock/subsys/$servicename ] ; then
114
echo $"Reloading rules configuration..."
115
kill -s 12 `cat ${pidfile}`
117
if [ $RETVAL -eq 0 ] ; then
123
log_failure_msg "$servicename is not running."
127
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"