fix: 修复待机控制器的 context 使用和忙循环问题

- interval: 添加 Sleep 避免默认分支的忙循环(CPU 100%)
- cron: 使用 context.Background() 确保定时任务完整执行,不受外部取消影响
- wait_card: 使用 context.Background() 确保读卡器监听完整执行

这些修复确保了关键操作能够完整运行,同时避免 CPU 资源浪费。
This commit is contained in:
2026-04-08 14:25:56 +08:00
parent bee3b98798
commit e31fca22c8
3 changed files with 9 additions and 4 deletions

View File

@@ -28,6 +28,8 @@ func Interval(interval int64, play func(c context.Context) error) func(c context
case <-c.Done():
return nil
default:
// 避免忙循环,短暂休眠
time.Sleep(10 * time.Millisecond)
}
}
}