mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 01:10:29 +08:00
优化任务Badge检查频率
This commit is contained in:
@@ -3,23 +3,38 @@ package tasks
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CheckAction struct {
|
type CheckAction struct {
|
||||||
actionutils.ParentAction
|
actionutils.ParentAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CheckAction) RunPost(params struct{}) {
|
func (this *CheckAction) RunPost(params struct {
|
||||||
resp, err := this.RPC().NodeTaskRPC().ExistsNodeTasks(this.AdminContext(), &pb.ExistsNodeTasksRequest{
|
IsDoing bool
|
||||||
ExcludeTypes: []string{"ipItemChanged"},
|
HasError bool
|
||||||
})
|
IsUpdated bool
|
||||||
if err != nil {
|
}) {
|
||||||
this.ErrorPage(err)
|
var maxTries = 10
|
||||||
return
|
for i := 0; i < maxTries; i++ {
|
||||||
}
|
resp, err := this.RPC().NodeTaskRPC().ExistsNodeTasks(this.AdminContext(), &pb.ExistsNodeTasksRequest{
|
||||||
|
ExcludeTypes: []string{"ipItemChanged"},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.Data["isDoing"] = resp.ExistTasks
|
// 如果没有数据变化,继续查询
|
||||||
this.Data["hasError"] = resp.ExistError
|
if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError {
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["isDoing"] = resp.ExistTasks
|
||||||
|
this.Data["hasError"] = resp.ExistError
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,36 @@ package tasks
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CheckAction struct {
|
type CheckAction struct {
|
||||||
actionutils.ParentAction
|
actionutils.ParentAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CheckAction) RunPost(params struct{}) {
|
func (this *CheckAction) RunPost(params struct {
|
||||||
resp, err := this.RPC().DNSTaskRPC().ExistsDNSTasks(this.AdminContext(), &pb.ExistsDNSTasksRequest{})
|
IsDoing bool
|
||||||
if err != nil {
|
HasError bool
|
||||||
this.ErrorPage(err)
|
IsUpdated bool
|
||||||
return
|
}) {
|
||||||
}
|
var maxTries = 10
|
||||||
|
for i := 0; i < maxTries; i++ {
|
||||||
|
resp, err := this.RPC().DNSTaskRPC().ExistsDNSTasks(this.AdminContext(), &pb.ExistsDNSTasksRequest{})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.Data["isDoing"] = resp.ExistTasks
|
// 如果没有数据变化,继续查询
|
||||||
this.Data["hasError"] = resp.ExistError
|
if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError {
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["isDoing"] = resp.ExistTasks
|
||||||
|
this.Data["hasError"] = resp.ExistError
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,12 @@ Tea.context(function () {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$post("/clusters/tasks/check")
|
this.$post("/clusters/tasks/check")
|
||||||
|
.params({
|
||||||
|
isDoing: this.doingNodeTasks.isDoing ? 1 : 0,
|
||||||
|
hasError: this.doingNodeTasks.hasError ? 1 : 0,
|
||||||
|
isUpdated: this.doingNodeTasks.isUpdated ? 1 : 0
|
||||||
|
})
|
||||||
|
.timeout(60)
|
||||||
.success(function (resp) {
|
.success(function (resp) {
|
||||||
this.doingNodeTasks.isDoing = resp.data.isDoing
|
this.doingNodeTasks.isDoing = resp.data.isDoing
|
||||||
this.doingNodeTasks.hasError = resp.data.hasError
|
this.doingNodeTasks.hasError = resp.data.hasError
|
||||||
@@ -151,6 +157,12 @@ Tea.context(function () {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$post("/dns/tasks/check")
|
this.$post("/dns/tasks/check")
|
||||||
|
.params({
|
||||||
|
isDoing: this.doingDNSTasks.isDoing ? 1 : 0,
|
||||||
|
hasError: this.doingDNSTasks.hasError ? 1 : 0,
|
||||||
|
isUpdated: this.doingDNSTasks.isUpdated ? 1 : 0
|
||||||
|
})
|
||||||
|
.timeout(60)
|
||||||
.success(function (resp) {
|
.success(function (resp) {
|
||||||
this.doingDNSTasks.isDoing = resp.data.isDoing
|
this.doingDNSTasks.isDoing = resp.data.isDoing
|
||||||
this.doingDNSTasks.hasError = resp.data.hasError
|
this.doingDNSTasks.hasError = resp.data.hasError
|
||||||
|
|||||||
Reference in New Issue
Block a user