🎨 后台任务显示当前正在执行的任务

This commit is contained in:
Liang Ding 2023-02-06 22:17:39 +08:00
parent b9f44309cb
commit 9a7a155ac7
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -121,6 +121,11 @@ func StatusJob() {
item := map[string]interface{}{"action": action}
items = append(items, item)
}
if "" != currentTaskAction {
items = append([]map[string]interface{}{map[string]interface{}{"action": currentTaskAction}}, items...)
}
if 1 > len(items) {
items = []map[string]interface{}{}
}
@ -141,6 +146,8 @@ func ExecTaskJob() {
execTask(task)
}
var currentTaskAction string
func popTask() (ret *Task) {
queueLock.Lock()
defer queueLock.Unlock()
@ -166,6 +173,8 @@ func execTask(task *Task) {
}
}
currentTaskAction = task.Action
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
ch := make(chan bool, 1)