Documentation
¶
Index ¶
Constants ¶
View Source
const (
// CgroupRoot default cgroup2
CgroupRoot = "/sys/fs/cgroup"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CgroupManager ¶
type CgroupManager struct {
// Path of the cgroup relative to the cgroup root
Path string
// Resource configuration
Resource *ResourceConfig
}
CgroupManager manages cgroup v2 resources
func NewCgroupManager ¶
func NewCgroupManager(path string) *CgroupManager
NewCgroupManager creates a new CgroupManager instance
func (*CgroupManager) Apply ¶
func (c *CgroupManager) Apply(pid int) error
Apply ensures that the cgroup directory exists, writes the process IDs to the cgroup.procs file under the cgroup path, and the processes can be subject to the resource limits set by that cgroup
func (*CgroupManager) Destroy ¶
func (c *CgroupManager) Destroy() error
Destroy migrates all processes in the cgroup to the parent cgroup by reading cgroup.procs and writing the process IDs to the parent cgroup's cgroup.procs, then deletes the entire cgroup directory
func (*CgroupManager) Set ¶
func (c *CgroupManager) Set(res *ResourceConfig) error
type ResourceConfig ¶
type ResourceConfig struct {
MemoryLimit string // in bytes
CpuSet string // cpus the container can use, e.g., "0-1,3"
}
ResourceConfig holds resource limit configurations
Click to show internal directories.
Click to hide internal directories.