owncast/cmd/concurrentConnections_freebsd.go
Gabe Kangas b80ccc4966
WIP
2024-03-25 09:04:05 -07:00

25 lines
547 B
Go

//go:build freebsd
// +build freebsd
package cmd
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 = int64(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)
}