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:
parent
bdbee31b86
commit
facdadd7b0
@ -2,6 +2,7 @@ package asynq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"sync"
|
"sync"
|
||||||
@ -43,7 +44,8 @@ func (bg *Background) Run(handler TaskHandler) {
|
|||||||
sigs := make(chan os.Signal, 1)
|
sigs := make(chan os.Signal, 1)
|
||||||
signal.Notify(sigs, os.Interrupt, os.Kill)
|
signal.Notify(sigs, os.Interrupt, os.Kill)
|
||||||
<-sigs
|
<-sigs
|
||||||
fmt.Printf("\nStarting graceful shutdown...\n")
|
fmt.Println()
|
||||||
|
log.Println("[INFO] Starting graceful shutdown...")
|
||||||
}
|
}
|
||||||
|
|
||||||
// starts the background-task processing.
|
// starts the background-task processing.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package asynq
|
package asynq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -29,7 +28,7 @@ func newPoller(rdb *rdb, avgInterval time.Duration, zsets []string) *poller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *poller) terminate() {
|
func (p *poller) terminate() {
|
||||||
fmt.Print("Poller shutting down...")
|
log.Println("[INFO] Poller shutting down...")
|
||||||
// Signal the poller goroutine to stop polling.
|
// Signal the poller goroutine to stop polling.
|
||||||
p.done <- struct{}{}
|
p.done <- struct{}{}
|
||||||
}
|
}
|
||||||
@ -40,7 +39,7 @@ func (p *poller) start() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-p.done:
|
case <-p.done:
|
||||||
fmt.Println("Done")
|
log.Println("[INFO] Poller done.")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
p.exec()
|
p.exec()
|
||||||
|
@ -29,16 +29,16 @@ func newProcessor(rdb *rdb, numWorkers int, handler TaskHandler) *processor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) terminate() {
|
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.
|
// Signal the processor goroutine to stop processing tasks from the queue.
|
||||||
p.done <- struct{}{}
|
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
|
// block until all workers have released the token
|
||||||
for i := 0; i < cap(p.sema); i++ {
|
for i := 0; i < cap(p.sema); i++ {
|
||||||
p.sema <- struct{}{}
|
p.sema <- struct{}{}
|
||||||
}
|
}
|
||||||
fmt.Println("Done")
|
log.Println("[INFO] All workers have finished.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) start() {
|
func (p *processor) start() {
|
||||||
@ -49,7 +49,7 @@ func (p *processor) start() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-p.done:
|
case <-p.done:
|
||||||
fmt.Println("Done")
|
log.Println("[INFO] Processor done.")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
p.exec()
|
p.exec()
|
||||||
|
Loading…
Reference in New Issue
Block a user