mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Automatically increase the process ulimit to maximum available. fixes #168.
This commit is contained in:
parent
ae9cc09b04
commit
3e87d7a86e
1 changed files with 172 additions and 157 deletions
|
@ -25,6 +25,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -155,6 +156,20 @@ 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 err != nil {
|
||||
fmt.Println("Error Setting rLimit ", err)
|
||||
}
|
||||
}
|
||||
|
||||
watcher, err := watcher.New(1 * time.Second)
|
||||
var wg sync.WaitGroup
|
||||
|
||||
|
|
Loading…
Reference in a new issue