MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / checkClusterConfig

Method checkClusterConfig

internal/nodes/node.go:532–572  ·  view source on GitHub ↗

检查集群设置

()

Source from the content-addressed store, hash-verified

530
531// 检查集群设置
532func (this *Node) checkClusterConfig() error {
533 config, err := configs.LoadClusterConfig()
534 if err != nil {
535 return err
536 }
537 rpcClient, err := rpc.NewRPCClient(&configs.APIConfig{
538 RPCEndpoints: config.RPCEndpoints,
539 RPCDisableUpdate: config.RPCDisableUpdate,
540 NodeId: config.ClusterId,
541 Secret: config.Secret,
542 })
543 if err != nil {
544 return err
545 }
546
547 remotelogs.Debug("NODE", "registering node to cluster ...")
548 resp, err := rpcClient.NodeRPC.RegisterClusterNode(rpcClient.ClusterContext(config.ClusterId, config.Secret), &pb.RegisterClusterNodeRequest{Name: HOSTNAME})
549 if err != nil {
550 return err
551 }
552 remotelogs.Debug("NODE", "registered successfully")
553
554 // 写入到配置文件中
555 if len(resp.Endpoints) == 0 {
556 resp.Endpoints = []string{}
557 }
558 var apiConfig = &configs.APIConfig{
559 RPCEndpoints: resp.Endpoints,
560 RPCDisableUpdate: false,
561 NodeId: resp.UniqueId,
562 Secret: resp.Secret,
563 }
564 remotelogs.Debug("NODE", "writing 'configs/"+configs.ConfigFileName+"' ...")
565 err = apiConfig.WriteFile(Tea.ConfigFile(configs.ConfigFileName))
566 if err != nil {
567 return err
568 }
569 remotelogs.Debug("NODE", "wrote 'configs/"+configs.ConfigFileName+"' successfully")
570
571 return nil
572}
573
574// 监听一些信号
575func (this *Node) listenSignals() {

Callers 1

syncConfigMethod · 0.95

Calls 5

ClusterContextMethod · 0.95
LoadClusterConfigFunction · 0.92
NewRPCClientFunction · 0.92
DebugFunction · 0.92
WriteFileMethod · 0.80

Tested by

no test coverage detected