Automatically increase the process ulimit to maximum available. fixes #168.

This commit is contained in:
spf13 2014-02-01 12:51:11 -05:00
parent ae9cc09b04
commit 3e87d7a86e

View file

@ -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