执行IP名单更新任务时防止阻塞/优化节点升级代码

This commit is contained in:
刘祥超
2022-08-01 18:54:54 +08:00
parent a72b025900
commit 6f843b071a
2 changed files with 16 additions and 5 deletions

View File

@@ -297,7 +297,12 @@ func (this *Node) loop() error {
for _, task := range tasksResp.NodeTasks {
switch task.Type {
case "ipItemChanged":
iplibrary.IPListUpdateNotify <- true
// 防止阻塞
select {
case iplibrary.IPListUpdateNotify <- true:
default:
}
// 修改为已同步
_, err = rpcClient.NodeTaskRPC().ReportNodeTaskDone(nodeCtx, &pb.ReportNodeTaskDoneRequest{
@@ -334,11 +339,12 @@ func (this *Node) loop() error {
if err != nil {
return err
}
case "nodeVersionChanged":
if !sharedUpgradeManager.IsInstalling() {
goman.New(func() {
sharedUpgradeManager.Start()
})
}
case "scriptsChanged":
err = this.reloadCommonScripts()
if err != nil {

View File

@@ -69,6 +69,11 @@ func (this *UpgradeManager) Start() {
})
}
// IsInstalling 检查是否正在安装
func (this *UpgradeManager) IsInstalling() bool {
return this.isInstalling
}
func (this *UpgradeManager) install() error {
// 检查是否有已下载但未安装成功的
if len(this.lastFile) > 0 {