-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_cgroups.in
executable file
·41 lines (33 loc) · 1.53 KB
/
create_cgroups.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
# This script will create cgroups for DOMjudge to use in /sys/fs/cgroup/
# They need to be re-created after system boot; you may want to
# add this script to an init script.
# Change the following to the user you start the judgedaemon as.
# (hence: not the 'domjudge-run' user!)
JUDGEHOSTUSER=@DOMJUDGE_USER@
CGROUPBASE=@judgehost_cgroupdir@
for i in cpuset memory; do
mkdir -p $CGROUPBASE/$i
if [ ! -d $CGROUPBASE/$i/ ]; then
if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then
echo "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue.
To fix this, please make the following changes:
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT
2. Run update-grub
3. Reboot" >&2
exit 1
fi
fi
mkdir -p $CGROUPBASE/$i/domjudge
done
if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then
echo "Error: cgroup support missing memory features in running kernel. Unable to continue.
To fix this, please make the following changes:
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT
2. Run update-grub
3. Reboot" >&2
exit 1
fi
chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge
cat $CGROUPBASE/cpuset/cpuset.cpus > $CGROUPBASE/cpuset/domjudge/cpuset.cpus
cat $CGROUPBASE/cpuset/cpuset.mems > $CGROUPBASE/cpuset/domjudge/cpuset.mems