defer recover

This commit is contained in:
ravilushqa 2022-08-21 12:41:52 +04:00 committed by Umputun
parent 3cb546b015
commit 546c2609b0

View File

@ -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)