mirror of
https://github.com/tuna/tunasync.git
synced 2025-04-20 11:42:43 +00:00
cgroupv2: change newCgroupHook interface
This commit is contained in:
parent
27c33f86b3
commit
2949b9c58c
@ -62,7 +62,12 @@ func waitExec () {
|
|||||||
panic("Exec failed.")
|
panic("Exec failed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCgroupHook(p mirrorProvider, basePath, baseGroup, subsystem string, memLimit MemBytes) *cgroupHook {
|
func newCgroupHook(p mirrorProvider, cfg cgroupConfig, memLimit MemBytes) *cgroupHook {
|
||||||
|
var (
|
||||||
|
basePath = cfg.BasePath
|
||||||
|
baseGroup = cfg.Group
|
||||||
|
subsystem = cfg.Subsystem
|
||||||
|
)
|
||||||
if basePath == "" {
|
if basePath == "" {
|
||||||
basePath = "/sys/fs/cgroup"
|
basePath = "/sys/fs/cgroup"
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,8 @@ sleep 30
|
|||||||
provider, err := newCmdProvider(c)
|
provider, err := newCmdProvider(c)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
cg := newCgroupHook(provider, "/sys/fs/cgroup", "tunasync", "cpu", 0)
|
cgcf := cgroupConfig{BasePath: "/sys/fs/cgroup", Group: "tunasync", Subsystem: "cpu"}
|
||||||
|
cg := newCgroupHook(provider, cgcf, 0)
|
||||||
provider.AddHook(cg)
|
provider.AddHook(cg)
|
||||||
|
|
||||||
err = cg.preExec()
|
err = cg.preExec()
|
||||||
@ -133,7 +134,8 @@ sleep 30
|
|||||||
provider, err := newRsyncProvider(c)
|
provider, err := newRsyncProvider(c)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
cg := newCgroupHook(provider, "/sys/fs/cgroup", "tunasync", "cpu", 512 * units.MiB)
|
cgcf := cgroupConfig{BasePath: "/sys/fs/cgroup", Group: "tunasync", Subsystem: "cpu"}
|
||||||
|
cg := newCgroupHook(provider, cgcf, 512 * units.MiB)
|
||||||
provider.AddHook(cg)
|
provider.AddHook(cg)
|
||||||
|
|
||||||
err = cg.preExec()
|
err = cg.preExec()
|
||||||
|
@ -212,8 +212,7 @@ func newMirrorProvider(mirror mirrorConfig, cfg *Config) mirrorProvider {
|
|||||||
// Add Cgroup Hook
|
// Add Cgroup Hook
|
||||||
provider.AddHook(
|
provider.AddHook(
|
||||||
newCgroupHook(
|
newCgroupHook(
|
||||||
provider, cfg.Cgroup.BasePath, cfg.Cgroup.Group,
|
provider, cfg.Cgroup, mirror.MemoryLimit,
|
||||||
cfg.Cgroup.Subsystem, mirror.MemoryLimit,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user