Commit ef19c1cd authored by vicotor's avatar vicotor

add log

parent e840deaa
...@@ -142,8 +142,10 @@ func (n *Node) Loop(idx int) { ...@@ -142,8 +142,10 @@ func (n *Node) Loop(idx int) {
client.Close() client.Close()
return return
case task := <-taskCh: case t := <-taskCh:
log.WithField("task", task).Info("get task") go func(task *odysseus.TaskContent) {
l := log.WithField("task-id", task.TaskId)
l.WithField("task", task).Info("get task")
for { for {
worker, err := PopWorker(n.rdb) worker, err := PopWorker(n.rdb)
if err == ErrNoWorker { if err == ErrNoWorker {
...@@ -154,26 +156,29 @@ func (n *Node) Loop(idx int) { ...@@ -154,26 +156,29 @@ func (n *Node) Loop(idx int) {
TaskIsSucceed: false, TaskIsSucceed: false,
TaskError: err.Error(), TaskError: err.Error(),
} }
l.WithError(err).Error("pop worker failed")
postReceipt(task, result, err) postReceipt(task, result, err)
err = postResult(task, result) err = postResult(task, result)
if err != nil { if err != nil {
log.WithError(err).Error("post task result failed") l.WithError(err).Error("post task result failed")
} }
break break
} }
if err != nil { if err != nil {
log.WithError(err).Error("pop worker failed") l.WithError(err).Error("pop worker failed")
continue continue
} }
err = DispatchTask(worker, task) err = DispatchTask(worker, task)
if err != nil { if err != nil {
log.WithError(err).Error("dispatch task failed") l.WithError(err).Error("dispatch task failed")
continue continue
} else { } else {
l.WithField("task-id", task.TaskId).Info("dispatch task success")
break break
} }
} }
}(t)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment