Skip to content

Commit

Permalink
Prevent log warnings and errors for mac (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoile authored Jun 14, 2024
1 parent b96c565 commit e5d75aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
13 changes: 8 additions & 5 deletions service/rtc/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,15 @@ func createUDPConnsForAddr(log mlog.LoggerIFace, network, listenAddress string)
log.Info(fmt.Sprintf("rtc: server is listening on udp %s", listenAddress))
}

if err := udpConn.(*net.UDPConn).SetWriteBuffer(udpSocketBufferSize); err != nil {
log.Warn("rtc: failed to set udp send buffer", mlog.Err(err))
}
// Mac by default cannot set socket buffers > 8mb
if runtime.GOOS != "darwin" {
if err := udpConn.(*net.UDPConn).SetWriteBuffer(udpSocketBufferSize); err != nil {
log.Warn("rtc: failed to set udp send buffer", mlog.Err(err))
}

if err := udpConn.(*net.UDPConn).SetReadBuffer(udpSocketBufferSize); err != nil {
log.Warn("rtc: failed to set udp receive buffer", mlog.Err(err))
if err := udpConn.(*net.UDPConn).SetReadBuffer(udpSocketBufferSize); err != nil {
log.Warn("rtc: failed to set udp receive buffer", mlog.Err(err))
}
}

connFile, err := udpConn.(*net.UDPConn).File()
Expand Down
20 changes: 13 additions & 7 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ func New(cfg Config) (*Service, error) {

s.log.Info("rtcd: starting up", getVersionInfo().logFields()...)

proc, err := procfs.NewDefaultFS()
if err != nil {
s.log.Error("failed to create proc file-system", mlog.Err(err))
}
s.proc = proc
// Mac does not have /proc/stat
if runtime.GOOS != "darwin" {
proc, err := procfs.NewDefaultFS()
if err != nil {
s.log.Error("failed to create proc file-system", mlog.Err(err))
}
s.proc = proc

go s.collectSystemInfo()
go s.collectSystemInfo()
}

s.store, err = store.New(cfg.Store.DataSource)
if err != nil {
Expand Down Expand Up @@ -116,7 +119,10 @@ func New(cfg Config) (*Service, error) {
s.apiServer.RegisterHandleFunc("/register", s.registerClient)
s.apiServer.RegisterHandleFunc("/unregister", s.unregisterClient)
s.apiServer.RegisterHandler("/ws", s.wsServer)
s.apiServer.RegisterHandleFunc("/system", s.getSystemInfo)

if runtime.GOOS != "darwin" {
s.apiServer.RegisterHandleFunc("/system", s.getSystemInfo)
}

if val := os.Getenv("PERF_PROFILES"); val == "true" {
runtime.SetMutexProfileFraction(5)
Expand Down

0 comments on commit e5d75aa

Please sign in to comment.