Skip to content

Instantly share code, notes, and snippets.

@liquidgecka
Created August 8, 2014 16:19
Show Gist options
  • Save liquidgecka/40159661be6a8fa2b9b8 to your computer and use it in GitHub Desktop.
Save liquidgecka/40159661be6a8fa2b9b8 to your computer and use it in GitHub Desktop.
cgroup init upstart config
NAME="example"
TASKS_OWNER="user1"
TASKS_GROUP="group1"
description "cgroup configuration initialization"
author "Brady Catherman <brady@orchestrate.io>"
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