Add a global panic handler to ensure we log panics

This commit is contained in:
Marc Brooks 2025-11-10 23:22:18 -06:00
parent b6c1e49803
commit 96c005b58c
No known key found for this signature in database
GPG Key ID: 583A6AF2D6AE1DC6
1 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,14 @@ var appCtx context.Context
func Main() { func Main() {
logger.Log().Msg("JetKVM Starting Up") logger.Log().Msg("JetKVM Starting Up")
// add recover to ensure we log out any panic
defer func() {
if r := recover(); r != nil {
logger.Panic().Interface("recovered", r).Msg("Uncaught panic")
}
}()
LoadConfig() LoadConfig()
var cancel context.CancelFunc var cancel context.CancelFunc