diff --git a/engine/api/cache/redis.go b/engine/api/cache/redis.go index 077025d80a..28ff527a3c 100644 --- a/engine/api/cache/redis.go +++ b/engine/api/cache/redis.go @@ -233,10 +233,11 @@ func (s *RedisStore) DequeueWithContext(c context.Context, queueName string, wai } var elem string - ticker := time.NewTicker(waitDuration).C + ticker := time.NewTicker(waitDuration) + defer ticker.Stop() for elem == "" { select { - case <-ticker: + case <-ticker.C: if c.Err() != nil { return c.Err() } diff --git a/engine/cdn/cdn_log.go b/engine/cdn/cdn_log.go index 7fd6d42b6c..beacf83e38 100644 --- a/engine/cdn/cdn_log.go +++ b/engine/cdn/cdn_log.go @@ -277,13 +277,11 @@ func (s *Service) getHatchery(ctx context.Context, hatcheryID int64, hatcheryNam } func (s *Service) waitingJobs(ctx context.Context) { - tick := time.NewTicker(250 * time.Millisecond) - defer tick.Stop() for { select { case <-ctx.Done(): return - case _ = <-tick.C: + default: // List all queues keyListQueue := cache.Key(keyJobLogQueue, "*") listKeys, err := s.Cache.Keys(keyListQueue) @@ -312,6 +310,7 @@ func (s *Service) waitingJobs(ctx context.Context) { } }) } + time.Sleep(250 * time.Millisecond) } } } @@ -332,6 +331,7 @@ func (s *Service) dequeueJobMessages(ctx context.Context, jobLogsQueueKey string }() tick := time.NewTicker(5 * time.Second) + defer tick.Stop() for { select { case <-ctx.Done():