owncast/core/chat/concurrentConnections.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

26 lines
592 B
Go

// nolint:goimports
//go:build !freebsd && !windows
// +build !freebsd,!windows
package chat
import (
"syscall"
log "github.com/sirupsen/logrus"
)
func setSystemConcurrentConnectionLimit(limit int64) {
var rLimit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
log.Fatalln(err)
}
originalLimit := rLimit.Cur
rLimit.Cur = uint64(limit)
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
log.Fatalln(err)
}
log.Traceln("Max process connection count changed from system limit of", originalLimit, "to", limit)
}