From cf1886e04b004a6c901e8b07514589a04cedf939 Mon Sep 17 00:00:00 2001 From: HuKeping Date: Thu, 26 Feb 2015 19:53:55 +0800 Subject: [PATCH] Feature: option for disable OOM killer Add cgroup support for disable OOM killer. Signed-off-by: Hu Keping --- sysinfo/sysinfo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index b6087ff..e679aab 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -18,6 +18,7 @@ type SysInfo struct { CpuCfsQuota bool IPv4ForwardingDisabled bool AppArmor bool + OomKillDisable bool } // New returns a new SysInfo, using the filesystem to detect which features the kernel supports. @@ -36,6 +37,12 @@ func New(quiet bool) *SysInfo { if !sysInfo.SwapLimit && !quiet { logrus.Warn("Your kernel does not support swap memory limit.") } + + _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.oom_control")) + sysInfo.OomKillDisable = err == nil + if !sysInfo.OomKillDisable && !quiet { + logrus.Warnf("Your kernel does not support oom control.") + } } if cgroupCpuMountpoint, err := cgroups.FindCgroupMountpoint("cpu"); err != nil {