Skip to content

Commit

Permalink
doing panic recovery wrong this whole time...
Browse files Browse the repository at this point in the history
  • Loading branch information
parMaster committed Oct 27, 2023
1 parent 44ebe17 commit 379d0c8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,6 @@ func main() {
// Graceful termination
ctx, cancel := context.WithCancel(context.Background())
go func() {
if x := recover(); x != nil {
log.Printf("[WARN] run time panic:\n%v", x)
panic(x)
}

// catch signal and invoke graceful termination
stop := make(chan os.Signal, 1)
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
Expand All @@ -553,5 +548,11 @@ func main() {
cancel()
}()

defer func() {
if x := recover(); x != nil {
log.Printf("[WARN] run time panic: %+v", x)
}
}()

NewWorker(conf).Run(ctx)
}

0 comments on commit 379d0c8

Please sign in to comment.