mirror of
https://github.com/bluenviron/mediamtx
synced 2024-12-24 15:42:28 +00:00
try to raise the number of file descriptors that can be opened to remove limits on number of connected clients (#193)
This commit is contained in:
parent
d40a8bb144
commit
fb0e900eb5
29
internal/rlimit/rlimit_unix.go
Normal file
29
internal/rlimit/rlimit_unix.go
Normal file
@ -0,0 +1,29 @@
|
||||
// +build !windows
|
||||
|
||||
package rlimit
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Raise raises the number of file descriptors that can be opened.
|
||||
func Raise() error {
|
||||
var rlim syscall.Rlimit
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rlim.Cur = 999999
|
||||
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
7
internal/rlimit/rlimit_win.go
Normal file
7
internal/rlimit/rlimit_win.go
Normal file
@ -0,0 +1,7 @@
|
||||
// +build windows
|
||||
|
||||
package rlimit
|
||||
|
||||
func Raise() error {
|
||||
return nil
|
||||
}
|
6
main.go
6
main.go
@ -16,6 +16,7 @@ import (
|
||||
"github.com/aler9/rtsp-simple-server/internal/metrics"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pprof"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rlimit"
|
||||
"github.com/aler9/rtsp-simple-server/internal/serverrtmp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/serverrtsp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
@ -56,6 +57,11 @@ func newProgram(args []string) (*program, bool) {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// on Linux, try to raise the number of file descriptors that can be opened
|
||||
// to allow the maximum possible number of clients
|
||||
// do not check for errors
|
||||
rlimit.Raise()
|
||||
|
||||
p := &program{
|
||||
confPath: *argConfPath,
|
||||
terminate: make(chan struct{}),
|
||||
|
Loading…
Reference in New Issue
Block a user