diff --git a/manager.go b/manager.go index c04d742..ceb8665 100644 --- a/manager.go +++ b/manager.go @@ -35,6 +35,12 @@ type ComponentsAreReady struct { func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsAreReady) error { go func() error { + defer func(ctx context.Context) { + err := m.shutdown(ctx) + if err != nil { + panic(err) + } + }(ctx) m.initLifetime() err := m.init(ctx) if err != nil { @@ -53,10 +59,6 @@ func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsA return err } - err = m.shutdown(ctx) - if err != nil { - return err - } return nil }() return nil