2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-04-19 12:55:51 +08:00

Log warning and info messages when unfinished tasks get aborted

This commit is contained in:
Ken Hibino
2019-12-18 18:55:08 -08:00
parent b2bc0ef91c
commit 33e9da953d
3 changed files with 25 additions and 7 deletions

View File

@@ -126,6 +126,7 @@ func (p *processor) exec() {
select {
case <-p.quit:
// time is up, quit this worker goroutine.
log.Printf("[WARN] Terminating in-progress task %+v\n", msg)
return
case resErr := <-resCh:
// Note: One of three things should happen.
@@ -150,10 +151,13 @@ func (p *processor) exec() {
// restore moves all tasks from "in-progress" back to queue
// to restore all unfinished tasks.
func (p *processor) restore() {
err := p.rdb.RestoreUnfinished()
n, err := p.rdb.RestoreUnfinished()
if err != nil {
log.Printf("[ERROR] Could not restore unfinished tasks: %v\n", err)
}
if n > 0 {
log.Printf("[INFO] Restored %d unfinished tasks back to queue.\n", n)
}
}
func (p *processor) requeue(msg *rdb.TaskMessage) {