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-02-01 11:56:27 +08:00
|
|
|
"github.com/docker/libcontainer/configs"
|
2015-01-13 05:54:00 +08:00
|
|
|
)
|
|
|
|
|
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-02-01 11:56:27 +08:00
|
|
|
func NewCgroupManager(cgroups *configs.Cgroup) cgroups.Manager {
|
2015-01-13 05:54:00 +08:00
|
|
|
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-02-01 11:56:27 +08:00
|
|
|
func LoadCgroupManager(cgroups *configs.Cgroup, paths map[string]string) cgroups.Manager {
|
2015-01-14 23:47:26 +08:00
|
|
|
if systemd.UseSystemd() {
|
|
|
|
return &systemd.Manager{
|
|
|
|
Cgroups: cgroups,
|
|
|
|
Paths: paths,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &fs.Manager{
|
|
|
|
Cgroups: cgroups,
|
|
|
|
Paths: paths,
|
|
|
|
}
|
|
|
|
}
|