diff --git a/app/main.go b/app/main.go index f00469d..94c59d0 100644 --- a/app/main.go +++ b/app/main.go @@ -160,11 +160,6 @@ func run() error { 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, os.Interrupt, syscall.SIGTERM) @@ -173,6 +168,14 @@ func run() error { cancel() }() + defer func() { + // handle panic + if x := recover(); x != nil { + log.Printf("[WARN] run time panic:\n%v", x) + panic(x) + } + }() + providers, err := makeProviders() if err != nil { return fmt.Errorf("failed to make providers: %w", err)