2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-11-10 11:31:58 +08:00

Change shutdown message to use info level logging

This commit is contained in:
Ken Hibino 2019-11-29 07:14:28 -08:00
parent bdbee31b86
commit facdadd7b0
3 changed files with 9 additions and 8 deletions

View File

@ -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.

View File

@ -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()

View File

@ -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()