From e9e94d1d34f768a7aa316fba63da21b5693f3e0c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 6 Mar 2009 10:51:54 -0500 Subject: cgroup support () --- rc.d/init.d/functions | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 37ec2865..fe9dd3a3 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -181,6 +181,7 @@ daemon() { # Test syntax. local gotbase= force= nicelevel corelimit local pid base= user= nice= bg= pid_file= + local cgroup= nicelevel=0 while [ "$1" != "${1##[-+]}" ]; do case $1 in @@ -239,15 +240,29 @@ daemon() { # if they set NICELEVEL in /etc/sysconfig/foo, honor it [ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL" + # if they set CGROUP_DAEMON in /etc/sysconfig/foo, honor it + if [ -n "${CGROUP_DAEMON}" ]; then + if [ ! -x /usr/bin/cgexec ]; then + echo -n "Cgroups not installed"; warning + echo + else + cgroup="/usr/bin/cgexec"; + for i in $CGROUP_DAEMON; do + cgroup="$cgroup -g $i"; + done + fi + fi + # Echo daemon [ "${BOOTUP:-}" = "verbose" -a -z "${LSB:-}" ] && echo -n " $base" # And start it up. if [ -z "$user" ]; then - $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*" + $cgroup $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*" else - $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*" + $cgroup $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*" fi + [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup" } -- cgit v1.2.1