New creates a new cgroup control
(path string, resources *spec.LinuxResources)
| 390 | |
| 391 | // New creates a new cgroup control |
| 392 | func New(path string, resources *spec.LinuxResources) (*CgroupControl, error) { |
| 393 | cgroup2, err := IsCgroup2UnifiedMode() |
| 394 | if err != nil { |
| 395 | return nil, err |
| 396 | } |
| 397 | control := &CgroupControl{ |
| 398 | cgroup2: cgroup2, |
| 399 | path: path, |
| 400 | } |
| 401 | |
| 402 | if !cgroup2 { |
| 403 | controllers, err := getAvailableControllers(handlers, false) |
| 404 | if err != nil { |
| 405 | return nil, err |
| 406 | } |
| 407 | control.additionalControllers = controllers |
| 408 | } |
| 409 | |
| 410 | if err := control.initialize(); err != nil { |
| 411 | return nil, err |
| 412 | } |
| 413 | |
| 414 | return control, nil |
| 415 | } |
| 416 | |
| 417 | // NewSystemd creates a new cgroup control |
| 418 | func NewSystemd(path string) (*CgroupControl, error) { |