Snapshot của containerd/cgroups: 1.2k★ · Go · Backend. cgroups package for Go
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Go package for creating, managing, inspecting, and destroying cgroups.
The resources format for settings on the cgroup uses the OCI runtime-spec found
here.
Examples (v1)
Create a new cgroup
This creates a new cgroup using a static path for all subsystems under /test.
/sys/fs/cgroup/cpu/test
/sys/fs/cgroup/memory/test
etc....
It uses a single hierarchy and specifies cpu shares as a resource constraint and
uses the v1 implementation of cgroups.
import (
"github.com/containerd/cgroups/v3/cgroup2"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
res := cgroup2.Resources{}
// dummy PID of -1 is used for creating a "general slice" to be used as a parent cgroup.
// see https://github.com/containerd/cgroups/blob/1df78138f1e1e6ee593db155c6b369466f577651/v2/manager.go#L732-L735
m, err := cgroup2.NewSystemd("/", "my-cgroup-abc.slice", -1, &res)
if err != nil {
return err
}
Load an existing cgroup
m, err := cgroup2.LoadSystemd("/", "my-cgroup-abc.slice")
if err != nil {
return err
}
Delete a cgroup
m, err := cgroup2.LoadSystemd("/", "my-cgroup-abc.slice")
if err != nil {
return err
}
err = m.DeleteSystemd()
if err != nil {
return err
}
Kill all processes in a cgroup
m, err := cgroup2.LoadSystemd("/", "my-cgroup-abc.slice")
if err != nil {
return err
}
err = m.Kill()
if err != nil {
return err
}
Get and set cgroup type
m, err := cgroup2.LoadSystemd("/", "my-cgroup-abc.slice")
if err != nil {
return err
}
// https://www.kernel.org/doc/html/v5.0/admin-guide/cgroup-v2.html#threads
cgType, err := m.GetType()
if err != nil {
return err
}
fmt.Println(cgType)
err = m.SetType(cgroup2.Threaded)
if err != nil {
return err
}
Attention
All static path should not include /sys/fs/cgroup/ prefix, it should start with your own cgroups name
Project details
Cgroups is a containerd sub-project, licensed under the Apache 2.0 license.
As a containerd sub-project, you will find the:
containerd/cgroups có 1.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/containerd/cgroups. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
containerd/cgroups có những chủ đề gì?
GitHub topics của containerd/cgroups: "cgroups", "golang", "linux". TopGit xếp repo vào nhóm Backend.
containerd/cgroups có trang demo không?
Dự án có trang chủ ở https://containerd.io. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
containerd/cgroups còn đang phát triển không?
Commit gần nhất trên containerd/cgroups là 4 ngày trước (theo timestamp GitHub). Repo có 252 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
containerd/cgroups dùng license gì?
containerd/cgroups phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
containerd/cgroups viết bằng ngôn ngữ gì?
containerd/cgroups chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc thêm về containerd/cgroups ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/containerd/cgroups là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
cgroups có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về cgroups.