From aa2b3d69052ebd3d4246738aae68e925c6e9abfd Mon Sep 17 00:00:00 2001 From: goshado Date: Sat, 11 Jan 2025 20:12:50 +0200 Subject: [PATCH] fix: reduntant use of watcher.stop --- pkg/event_handler/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/event_handler/main.go b/pkg/event_handler/main.go index 1fa94b4..51a4e4b 100644 --- a/pkg/event_handler/main.go +++ b/pkg/event_handler/main.go @@ -27,24 +27,25 @@ func Start(ctx context.Context, stop context.CancelFunc, cfg *conf.GlobalConfig, Notifier: notifier, } go func() { + defer func() { + log.Print("[event handler] shutting down, stopping watcher") + watcher.Stop() + }() + for { select { case <-ctx.Done(): - log.Print("[event handler] context canceled, stopping watcher") - watcher.Stop() + log.Print("[event handler] context canceled, exiting") return case event, ok := <-watcher.ResultChan(): if !ok { log.Print("[event handler] result channel closed") - watcher.Stop() - stop() return } if err2 := handler.Handle(ctx, &event); err2 != nil { - log.Printf("[event handler] failed to Handle workflow event: %v", err2) + log.Printf("[event handler] failed to handle workflow event: %v", err2) } } } - }() }