Merge pull request #305 from hqhq/hq_add_softlimit_systemd
Add memory reservation support for systemd
This commit is contained in:
commit
cc84f2cc9b
|
@ -177,7 +177,6 @@ func (m *Manager) Apply(pid int) error {
|
|||
properties = append(properties,
|
||||
newProp("MemoryLimit", uint64(c.Memory)))
|
||||
}
|
||||
// TODO: MemoryReservation and MemorySwap not available in systemd
|
||||
|
||||
if c.CpuShares != 0 {
|
||||
properties = append(properties,
|
||||
|
@ -213,6 +212,7 @@ func (m *Manager) Apply(pid int) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO: MemoryReservation and MemorySwap not available in systemd
|
||||
if err := joinMemory(c, pid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -510,6 +510,12 @@ func joinMemory(c *configs.Cgroup, pid int) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if c.MemoryReservation > 0 {
|
||||
err = writeFile(path, "memory.soft_limit_in_bytes", strconv.FormatInt(c.MemoryReservation, 10))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if c.OomKillDisable {
|
||||
if err := writeFile(path, "memory.oom_control", "1"); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue