Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Freezer cgroup FTW

In a terminal start a server.

$ python -m SimpleHTTPServer 8000

In another terminal set up the cgroups freezer.

$ mkdir /sys/fs/cgroup/freezer
$ mount -t cgroup -ofreezer freezer /sys/fs/cgroup/freezer
$ mkdir /sys/fs/cgroup/freezer/0
 
# Add our server to our tasks.
$ echo $(pidof python) > /sys/fs/cgroup/freezer/0/tasks
 
# get status of the freezer subsystem 
$ cat /sys/fs/cgroup/freezer/0/freezer.state
THAWED

# freeze all tasks in the cgroup
$ echo FROZEN > /sys/fs/cgroup/freezer/0/freezer.state

# get the status
$ cat /sys/fs/cgroup/freezer/0/freezer.state
FREEZING
$ cat /sys/fs/cgroup/freezer/0/freezer.state
FROZEN

# send a request.... it will block
$ curl localhost:8000

# unfreeze all tasks in the cgroup
$ echo THAWED > /sys/fs/cgroup/freezer/0/freezer.state
$ cat /sys/fs/cgroup/freezer/0/freezer.state
THAWED

# our request from above will unblock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.