rework module shutdown process to cancel module context in defer

This commit is contained in:
Joel Wetzell
2026-05-27 20:50:33 -05:00
parent 52ca801fbd
commit 0b494fce91
21 changed files with 197 additions and 216 deletions
+5 -4
View File
@@ -66,7 +66,7 @@ func (t *TimeTimer) Start(ctx context.Context, inputHandler common.InputHandler)
t.cancel = cancel
t.timer = time.NewTimer(time.Millisecond * time.Duration(t.Duration))
for {
for t.ctx.Err() == nil {
select {
case <-t.ctx.Done():
return nil
@@ -76,15 +76,16 @@ func (t *TimeTimer) Start(ctx context.Context, inputHandler common.InputHandler)
}
}
}
<-t.ctx.Done()
t.logger.Debug("done")
return nil
}
func (t *TimeTimer) Stop() {
if t.cancel != nil {
t.cancel()
defer t.cancel()
}
if t.timer != nil {
t.timer.Stop()
t.timer = nil
}
t.logger.Debug("done")
}