owncast/core/chat/utils.go
Jack 651caeba91
Fix build for Windows (#1377) (#1506)
* Fix build for Windows (#1377)

* Add tests for windows
2021-10-31 14:01:22 -07:00

22 lines
466 B
Go

//go:build !windows
// +build !windows
package chat
import (
"syscall"
log "github.com/sirupsen/logrus"
)
func getMaximumConcurrentConnectionLimit() int64 {
var rLimit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
log.Fatalln(err)
}
// Return the limit to 70% of max so the machine doesn't die even if it's maxed out for some reason.
proposedLimit := int64(float32(rLimit.Max) * 0.7)
return proposedLimit
}