Set default max open files in spec

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #1355
Approved by: rhatdan
This commit is contained in:
Matthew Heon 2018-08-27 14:14:09 -04:00 committed by Atomic Bot
parent 822c327997
commit 9da94c454f
1 changed files with 11 additions and 0 deletions

View File

@ -444,13 +444,24 @@ func addRlimits(config *CreateConfig, g *generate.Generator) error {
err error
)
nofileSet := false
for _, u := range config.Resources.Ulimit {
if ul, err = units.ParseUlimit(u); err != nil {
return errors.Wrapf(err, "ulimit option %q requires name=SOFT:HARD, failed to be parsed", u)
}
if ul.Name == "nofile" {
nofileSet = true
}
g.AddProcessRlimits("RLIMIT_"+strings.ToUpper(ul.Name), uint64(ul.Hard), uint64(ul.Soft))
}
if !nofileSet {
g.AddProcessRlimits("RLIMIT_NOFILE", 1048576, 1048576)
}
return nil
}