try to raise the number of file descriptors that can be opened to remove limits on number of connected clients (#193)

This commit is contained in:
aler9
2021-03-19 13:37:14 +01:00
parent d40a8bb144
commit fb0e900eb5
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
// +build !windows
package rlimit
import (
"syscall"
)
// Raise raises the number of file descriptors that can be opened.
func Raise() error {
var rlim syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
if err != nil {
return err
}
rlim.Cur = 999999
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
if err != nil {
return err
}
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
if err != nil {
return err
}
return nil
}