2021-01-17 16:47:29 +08:00
|
|
|
package tasks
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
2023-01-07 19:34:40 +08:00
|
|
|
"time"
|
2021-01-17 16:47:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CheckAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 19:34:40 +08:00
|
|
|
func (this *CheckAction) RunPost(params struct {
|
|
|
|
|
IsDoing bool
|
|
|
|
|
HasError bool
|
|
|
|
|
IsUpdated bool
|
|
|
|
|
}) {
|
|
|
|
|
var maxTries = 10
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果没有数据变化,继续查询
|
|
|
|
|
if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError {
|
|
|
|
|
time.Sleep(3 * time.Second)
|
|
|
|
|
continue
|
|
|
|
|
}
|
2021-01-17 16:47:29 +08:00
|
|
|
|
2023-01-07 19:34:40 +08:00
|
|
|
this.Data["isDoing"] = resp.ExistTasks
|
|
|
|
|
this.Data["hasError"] = resp.ExistError
|
|
|
|
|
break
|
|
|
|
|
}
|
2021-01-17 16:47:29 +08:00
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|