exit after panic (#1392)

* let panics crash

* Revert "let panics crash"

This reverts commit 8027cccadd760bd6588ba7a0c699f80b9fda1f09.

* catch and log panics then os.Exit

* Recover only recovers, caller can exit

* only exit on pacic, still need Recover calls in goroutines
This commit is contained in:
Dan McFaul
2023-02-09 16:33:22 -07:00
committed by GitHub
parent bee4bcc158
commit ad7e075c18
5 changed files with 40 additions and 11 deletions
+7 -1
View File
@@ -3,6 +3,7 @@ package service
import (
"context"
"fmt"
"os"
"sync"
"time"
@@ -479,7 +480,12 @@ func (r *RoomManager) rtcSessionWorker(room *rtc.Room, participant types.LocalPa
pLogger.Debugw("RTC session finishing")
requestSource.Close()
}()
defer rtc.Recover(pLogger)
defer func() {
if r := rtc.Recover(pLogger); r != nil {
os.Exit(1)
}
}()
// send first refresh for cases when client token is close to expiring
_ = r.refreshToken(participant)
+6 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
@@ -263,7 +264,11 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// we would terminate the signal connection as well
_ = conn.Close()
}()
defer rtc.Recover(pLogger)
defer func() {
if r := rtc.Recover(pLogger); r != nil {
os.Exit(1)
}
}()
for {
select {
case <-done: