Created
August 8, 2014 16:19
-
-
Save liquidgecka/40159661be6a8fa2b9b8 to your computer and use it in GitHub Desktop.
cgroup init upstart config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NAME="example" | |
TASKS_OWNER="user1" | |
TASKS_GROUP="group1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "cgroup configuration initialization" | |
author "Brady Catherman <[email protected]>" | |
start on mounted MOUNTPOINT=/sys/fs/cgroup | |
emits cgroup | |
post-start script | |
if [ ! -d /etc/cgroup.d ] ; then | |
exit 0 | |
fi | |
/bin/cgroups-mount | |
# Walk through each config file loading it and then creating the | |
# groups contained with in. | |
find /etc/cgroup.d -maxdepth 1 -type f -name \*.conf | | |
while read file ; do | |
# Load the config | |
NAME="" | |
TASKS_OWNER="" | |
TASKS_GROUP="" | |
. "$file" | |
if [ -z "$NAME" ] ; then | |
echo "$file doesn't specify a name! Skipping" >&2 | |
continue | |
fi | |
# Make the directories. | |
for dir in /sys/fs/cgroup/* ; do | |
mkdir -p "$dir/$NAME" | |
if [ ! -z "$TASKS_OWNER" ] ; then | |
chown "$TASKS_OWNER" "$dir/$NAME/tasks" | |
fi | |
if [ ! -z "$TASKS_GROUP" ] ; then | |
chgrp "$TASKS_GROUP" "$dir/$NAME/tasks" | |
fi | |
done | |
done | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment