Skip to content

Instantly share code, notes, and snippets.

@jessfraz
Created July 24, 2018 22:23
Show Gist options
  • Save jessfraz/3d9d8e047f1dd645e44471e9c4c6512a to your computer and use it in GitHub Desktop.
Save jessfraz/3d9d8e047f1dd645e44471e9c4c6512a to your computer and use it in GitHub Desktop.

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