set rlimit in backend
Ted Unangst tedu@tedunangst.com
Mon, 15 Mar 2021 14:11:31 -0400
2 files changed,
11 insertions(+),
0 deletions(-)
M
backend.go
→
backend.go
@@ -94,6 +94,10 @@ lis, err := net.Listen("unix", sockname)
if err != nil { log.Panicf("unable to register shrinker: %s", err) } + err = setLimits() + if err != nil { + log.Printf("error setting backend limits: %s", err) + } for _, h := range backendhooks { h() }
M
sensors.go
→
sensors.go
@@ -41,3 +41,10 @@ sensors.CPU = time.Duration(usage.Utime.Nano()).Seconds()
return sensors } + +func setLimits() error { + var limit syscall.Rlimit + limit.Cur = 2 * 1024 * 1024 * 1024 + limit.Max = 2 * 1024 * 1024 * 1024 + return syscall.Setrlimit(syscall.RLIMIT_DATA, &limit) +}