mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 00:32:07 +00:00
Only change rLimit on OSX (where it is needed). Fixed #194
This commit is contained in:
parent
11ca84f8cb
commit
75c260fa1c
1 changed files with 13 additions and 10 deletions
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/spf13/nitro"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
@ -156,17 +157,19 @@ func buildSite(watching ...bool) (err error) {
|
|||
}
|
||||
|
||||
func NewWatcher(port int) error {
|
||||
var rLimit syscall.Rlimit
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||
if err != nil {
|
||||
fmt.Println("Error Getting Rlimit ", err)
|
||||
}
|
||||
if rLimit.Cur < rLimit.Max {
|
||||
rLimit.Max = 999999
|
||||
rLimit.Cur = 999999
|
||||
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||
if runtime.GOOS == "darwin" {
|
||||
var rLimit syscall.Rlimit
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||
if err != nil {
|
||||
fmt.Println("Error Setting rLimit ", err)
|
||||
fmt.Println("Unable to obtain rLimit", err)
|
||||
}
|
||||
if rLimit.Cur < rLimit.Max {
|
||||
rLimit.Max = 999999
|
||||
rLimit.Cur = 999999
|
||||
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to increase number of open files limit", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue