Take control over your live stream video by running it yourself. Streaming + chat out of the box.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
757 B

package chat
import (
"syscall"
log "github.com/sirupsen/logrus"
)
// Set the soft file handler limit as 70% of
// the max as the client connection limit.
func handleMaxConnectionCount() uint {
var rLimit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
panic(err)
}
originalLimit := rLimit.Cur
// Set the limit to 70% of max so the machine doesn't die even if it's maxed out for some reason.
proposedLimit := int(float32(rLimit.Max) * 0.7)
rLimit.Cur = uint64(proposedLimit)
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
panic(err)
}
log.Traceln("Max process connection count increased from", originalLimit, "to", proposedLimit)
return uint(float32(rLimit.Cur))
}