2023-04-25 03:49:29 +03:00
|
|
|
//go:build freebsd
|
2021-08-14 01:26:44 +03:00
|
|
|
// +build freebsd
|
|
|
|
|
|
|
|
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 {
|
2021-10-25 10:14:42 +03:00
|
|
|
log.Fatalln(err)
|
2021-08-14 01:26:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
originalLimit := rLimit.Cur
|
|
|
|
rLimit.Cur = int64(limit)
|
|
|
|
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
|
2021-10-25 10:14:42 +03:00
|
|
|
log.Fatalln(err)
|
2021-08-14 01:26:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
log.Traceln("Max process connection count changed from system limit of", originalLimit, "to", limit)
|
|
|
|
}
|