cgroups

cgroups for node

Usage no npm install needed!

<script type="module">
  import cgroups from 'https://cdn.skypack.dev/cgroups';
</script>

README

cgroups

This module is an experiment in exposing the cgroups "API" to node. Who knows what will happen...

Use

var cgroups = require('cgroups')

// Make a cgroup
cgroups.create('yolo', {cpuset:{cpus:'0'}}, function(err) {
    var child = chpr.spawn('bash')
    cgroups.movePid(child.pid, 'cpuset/yolo', function(err) {
        // the child is now in the cpuset/yolo cgroup limited to cpu 0
    })
})

API

create(name, resourceTree, callback)  // Make a cgroup
movePid(pid, path/to/group, callback) // Add pid to cgroup
remove(name, resourceTree, callback)  // Remove a cgroup
set(name, resourceTree, callback)     // Set values in cgroup
getGroups(pid, callback)              // Get cgroups for pid

enjoy.