diff --git a/background.go b/background.go index 3fe01d6..9aa9f6b 100644 --- a/background.go +++ b/background.go @@ -2,6 +2,7 @@ package asynq import ( "fmt" + "log" "os" "os/signal" "sync" @@ -43,7 +44,8 @@ func (bg *Background) Run(handler TaskHandler) { sigs := make(chan os.Signal, 1) signal.Notify(sigs, os.Interrupt, os.Kill) <-sigs - fmt.Printf("\nStarting graceful shutdown...\n") + fmt.Println() + log.Println("[INFO] Starting graceful shutdown...") } // starts the background-task processing. diff --git a/poller.go b/poller.go index 9fd0b86..808c582 100644 --- a/poller.go +++ b/poller.go @@ -1,7 +1,6 @@ package asynq import ( - "fmt" "log" "time" ) @@ -29,7 +28,7 @@ func newPoller(rdb *rdb, avgInterval time.Duration, zsets []string) *poller { } func (p *poller) terminate() { - fmt.Print("Poller shutting down...") + log.Println("[INFO] Poller shutting down...") // Signal the poller goroutine to stop polling. p.done <- struct{}{} } @@ -40,7 +39,7 @@ func (p *poller) start() { for { select { case <-p.done: - fmt.Println("Done") + log.Println("[INFO] Poller done.") return default: p.exec() diff --git a/processor.go b/processor.go index feffb2c..f6e198e 100644 --- a/processor.go +++ b/processor.go @@ -29,16 +29,16 @@ func newProcessor(rdb *rdb, numWorkers int, handler TaskHandler) *processor { } func (p *processor) terminate() { - fmt.Print("Processor shutting down...") + log.Println("[INFO] Processor shutting down...") // Signal the processor goroutine to stop processing tasks from the queue. p.done <- struct{}{} - fmt.Print("Waiting for all workers to finish...") + log.Println("[INFO] Waiting for all workers to finish...") // block until all workers have released the token for i := 0; i < cap(p.sema); i++ { p.sema <- struct{}{} } - fmt.Println("Done") + log.Println("[INFO] All workers have finished.") } func (p *processor) start() { @@ -49,7 +49,7 @@ func (p *processor) start() { for { select { case <-p.done: - fmt.Println("Done") + log.Println("[INFO] Processor done.") return default: p.exec()