mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	实现CPU线程数和修改节点的启用状态
This commit is contained in:
		@@ -2,6 +2,7 @@ package nodes
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/logs"
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"net/url"
 | 
			
		||||
@@ -45,6 +46,9 @@ func (this *ListenerManager) Start(node *nodeconfigs.NodeConfig) error {
 | 
			
		||||
	// 所有的新地址
 | 
			
		||||
	groupAddrs := []string{}
 | 
			
		||||
	availableServerGroups := node.AvailableGroups()
 | 
			
		||||
	if !node.IsOn {
 | 
			
		||||
		availableServerGroups = []*serverconfigs.ServerGroup{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(availableServerGroups) == 0 {
 | 
			
		||||
		logs.Println("LISTENER_MANAGER", "no available servers to startup")
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/logs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/rpc"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -101,8 +102,20 @@ func (this *Node) syncConfig(isFirstTime bool) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// max cpu
 | 
			
		||||
	if nodeConfig.MaxCPU > 0 && nodeConfig.MaxCPU < int32(runtime.NumCPU()) {
 | 
			
		||||
		runtime.GOMAXPROCS(int(nodeConfig.MaxCPU))
 | 
			
		||||
	} else {
 | 
			
		||||
		runtime.GOMAXPROCS(runtime.NumCPU())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 刷新配置
 | 
			
		||||
	logs.Println("NODE", "reload config ...")
 | 
			
		||||
	if isFirstTime {
 | 
			
		||||
		logs.Println("NODE", "reloading config ...")
 | 
			
		||||
	} else {
 | 
			
		||||
		logs.Println("NODE", "loading config ...")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nodeconfigs.ResetNodeConfig(nodeConfig)
 | 
			
		||||
	caches.SharedManager.UpdatePolicies(nodeConfig.AllCachePolicies())
 | 
			
		||||
	sharedWAFManager.UpdatePolicies(nodeConfig.AllHTTPFirewallPolicies())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user