Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions failsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"strings"
"sync"

"github.com/jetkvm/kvm/internal/supervisor"
)

const (
Expand Down Expand Up @@ -78,6 +80,10 @@ func checkFailsafeReason() {

// TODO: read the goroutine stack trace and check which goroutine is panicking
failsafeModeActive = true
if strings.Contains(failsafeCrashLog, supervisor.FailsafeReasonVideoMaxRestartAttemptsReached) {
failsafeModeReason = "video"
return
}
if strings.Contains(failsafeCrashLog, "runtime.cgocall") {
failsafeModeReason = "video"
return
Expand Down
3 changes: 2 additions & 1 deletion internal/native/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/Masterminds/semver/v3"
"github.com/jetkvm/kvm/internal/supervisor"
"github.com/jetkvm/kvm/internal/utils"
"github.com/rs/zerolog"
)
Expand Down Expand Up @@ -422,7 +423,7 @@ func (p *NativeProxy) restartProcess() error {
logger := p.logger.With().Uint("attempt", p.restarts).Uint("maxAttempts", p.options.MaxRestartAttempts).Logger()

if p.restarts >= p.options.MaxRestartAttempts {
logger.Fatal().Msg("max restart attempts reached, exiting")
logger.Fatal().Msgf("max restart attempts reached, exiting: %s", supervisor.FailsafeReasonVideoMaxRestartAttemptsReached)
return fmt.Errorf("max restart attempts reached")
}

Expand Down
2 changes: 2 additions & 0 deletions internal/supervisor/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ const (
ErrorDumpDir = "/userdata/jetkvm/crashdump" // The error dump directory is the directory where the error dumps are stored
ErrorDumpLastFile = "last-crash.log" // The error dump last file is the last error dump file
ErrorDumpTemplate = "jetkvm-%s.log" // The error dump template is the template for the error dump file

FailsafeReasonVideoMaxRestartAttemptsReached = "failsafe::video.max_restart_attempts_reached"
)