2015-01-13 05:54:00 +08:00
|
|
|
package manager
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/libcontainer/cgroups"
|
|
|
|
"github.com/docker/libcontainer/cgroups/fs"
|
|
|
|
"github.com/docker/libcontainer/cgroups/systemd"
|
|
|
|
)
|
|
|
|
|
2015-01-14 23:23:42 +08:00
|
|
|
// Create a new cgroup manager with specified configuration
|
2015-01-15 00:48:25 +08:00
|
|
|
// TODO this object is not really initialized until Apply() is called.
|
|
|
|
// Maybe make this to the equivalent of Apply() at some point?
|
|
|
|
// @vmarmol
|
2015-01-13 05:54:00 +08:00
|
|
|
func NewCgroupManager(cgroups *cgroups.Cgroup) cgroups.Manager {
|
|
|
|
if systemd.UseSystemd() {
|
|
|
|
return &systemd.Manager{
|
|
|
|
Cgroups: cgroups,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &fs.Manager{
|
|
|
|
Cgroups: cgroups,
|
|
|
|
}
|
|
|
|
}
|
2015-01-14 23:47:26 +08:00
|
|
|
|
2015-01-14 23:23:42 +08:00
|
|
|
// Restore a cgroup manager with specified configuration and state
|
2015-01-14 23:47:26 +08:00
|
|
|
func LoadCgroupManager(cgroups *cgroups.Cgroup, paths map[string]string) cgroups.Manager {
|
|
|
|
if systemd.UseSystemd() {
|
|
|
|
return &systemd.Manager{
|
|
|
|
Cgroups: cgroups,
|
|
|
|
Paths: paths,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &fs.Manager{
|
|
|
|
Cgroups: cgroups,
|
|
|
|
Paths: paths,
|
|
|
|
}
|
|
|
|
}
|