summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-04-06 17:40:35 +0200
committerBjørn Erik Pedersen <[email protected]>2019-04-07 00:53:55 +0200
commit708d4ceebd491c6a89f271311eb8d94d6b5d58bc (patch)
tree81eb1f551c757d4d2ab5828dc119fec195064f1d
parented65bda3b43f6149e41ddb049cbb295a82473bc9 (diff)
downloadhugo-708d4ceebd491c6a89f271311eb8d94d6b5d58bc.tar.gz
hugo-708d4ceebd491c6a89f271311eb8d94d6b5d58bc.zip
Adjust rlimit logic
Closes #5821
-rw-r--r--commands/limit_darwin.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/commands/limit_darwin.go b/commands/limit_darwin.go
index 7dce75b3e..6799f37b1 100644
--- a/commands/limit_darwin.go
+++ b/commands/limit_darwin.go
@@ -36,14 +36,17 @@ This is primarily to ensure that Hugo can watch enough files on some OSs`,
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
- return newSystemError("Error Getting Rlimit ", err)
+ return newSystemError("Error Getting rlimit ", err)
}
jww.FEEDBACK.Println("Current rLimit:", rLimit)
+ if rLimit.Cur >= newRlimit {
+ return nil
+ }
+
jww.FEEDBACK.Println("Attempting to increase limit")
- rLimit.Max = 999999
- rLimit.Cur = 999999
+ rLimit.Cur = newRlimit
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return newSystemError("Error Setting rLimit ", err)
@@ -61,18 +64,21 @@ This is primarily to ensure that Hugo can watch enough files on some OSs`,
return &limitCmd{baseCmd: newBaseCmd(ccmd)}
}
+const newRlimit = 10240
+
func tweakLimit() {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
- jww.ERROR.Println("Unable to obtain rLimit", err)
+ jww.WARN.Println("Unable to get rlimit:", err)
+ return
}
- if rLimit.Cur < rLimit.Max {
- rLimit.Max = 64000
- rLimit.Cur = 64000
+ if rLimit.Cur < newRlimit {
+ rLimit.Cur = newRlimit
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
- jww.WARN.Println("Unable to increase number of open files limit", err)
+ // This may not succeed, see https://github.com/golang/go/issues/30401
+ jww.INFO.Println("Unable to increase number of open files limit:", err)
}
}
}