From 760be3e231a1999df1959f15f1c44913120caa68 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Fri, 17 May 2024 16:29:06 -0400 Subject: [PATCH] patch: fix linter - removing these errors and defers since we're getting rid of our centralize lifecycle functions in main soon --- cmd/xmidt-agent/main.go | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/cmd/xmidt-agent/main.go b/cmd/xmidt-agent/main.go index 603fbeb..89be17c 100644 --- a/cmd/xmidt-agent/main.go +++ b/cmd/xmidt-agent/main.go @@ -5,10 +5,8 @@ package main import ( "context" - "errors" "fmt" "os" - "runtime/debug" "time" "github.com/alecthomas/kong" @@ -30,12 +28,6 @@ const ( applicationName = "xmidt-agent" ) -var ( - ErrLifecycleStartPanic = errors.New("panic occured during fx's lifecycle Start") - ErrLifecycleStopPanic = errors.New("panic occured during fx's lifecycle Stop") - ErrLifecycleShutdownPanic = errors.New("panic occured during fx's lifecycle Shutdown") -) - // These match what goreleaser provides. var ( commit = "undefined" @@ -235,14 +227,6 @@ func onStart(cred *credentials.Credentials, ws *websocket.Websocket, libParodus logger = logger.Named("on_start") return func(ctx context.Context) (err error) { - // err is set during a panic recovery in order to allow fx to rolling back - defer func() { - if r := recover(); nil != r { - err = ErrLifecycleStartPanic - logger.Error("stacktrace from panic", zap.String("stacktrace", string(debug.Stack())), zap.Any("panic", r), zap.Error(err)) - } - }() - if err = ctx.Err(); err != nil { return err } @@ -272,20 +256,6 @@ func onStop(ws *websocket.Websocket, libParodus *libparodus.Adapter, qos *qos.Ha logger = logger.Named("on_stop") return func(context.Context) (err error) { - // err is set during a panic recovery in order to manually trigger - // the shutdown of the application by sending a signal to all open Done channels - defer func() { - if r := recover(); nil != r { - err = ErrLifecycleStopPanic - logger.Error("stacktrace from panic", zap.String("stacktrace", string(debug.Stack())), zap.Any("panic", r), zap.Error(err)) - } - - if err2 := shutdowner.Shutdown(); err2 != nil { - err = errors.Join(err, err2, ErrLifecycleShutdownPanic) - logger.Error("encountered error trying to shutdown app: ", zap.Error(err)) - } - }() - if ws == nil { logger.Debug("websocket disabled") return nil