func (a *Agent) Start() { var err error // send a first reset event to the analyzers a.Graph.DelSubGraph(a.Root) addr, port, err := config.GetAnalyzerClientAddr() if err != nil { logging.GetLogger().Errorf("Unable to parse analyzer client %s", err.Error()) os.Exit(1) } if addr != "" { a.Gclient = graph.NewAsyncClient(addr, port, "/ws/graph") graph.NewForwarder(a.Gclient, a.Graph) a.Gclient.Connect() } a.TopologyProbeBundle = tprobes.NewTopologyProbeBundleFromConfig(a.Graph, a.Root) a.TopologyProbeBundle.Start() a.FlowProbeBundle = fprobes.NewFlowProbeBundleFromConfig(a.TopologyProbeBundle, a.Graph) a.FlowProbeBundle.Start() go a.TopologyServer.ListenAndServe() go a.GraphServer.ListenAndServe() }
func (a *Agent) Start() { var err error go a.WSServer.ListenAndServe() addr, port, err := config.GetAnalyzerClientAddr() if err != nil { logging.GetLogger().Errorf("Unable to parse analyzer client %s", err.Error()) os.Exit(1) } if addr != "" { authOptions := &shttp.AuthenticationOpts{ Username: config.GetConfig().GetString("agent.analyzer_username"), Password: config.GetConfig().GetString("agent.analyzer_password"), } authClient := shttp.NewAuthenticationClient(addr, port, authOptions) a.WSClient, err = shttp.NewWSAsyncClient(addr, port, "/ws", authClient) if err != nil { logging.GetLogger().Errorf("Unable to instantiate analyzer client %s", err.Error()) os.Exit(1) } graph.NewForwarder(a.WSClient, a.Graph) a.WSClient.Connect() // send a first reset event to the analyzers a.Graph.DelSubGraph(a.Root) } a.TopologyProbeBundle = tprobes.NewTopologyProbeBundleFromConfig(a.Graph, a.Root) a.TopologyProbeBundle.Start() a.FlowProbeBundle = fprobes.NewFlowProbeBundleFromConfig(a.TopologyProbeBundle, a.Graph) a.FlowProbeBundle.Start() if addr != "" { a.EtcdClient, err = etcd.NewEtcdClientFromConfig() if err != nil { logging.GetLogger().Errorf("Unable to start etcd client %s", err.Error()) os.Exit(1) } captureHandler := &api.BasicApiHandler{ ResourceHandler: &api.CaptureHandler{}, EtcdKeyAPI: a.EtcdClient.KeysApi, } l, err := fprobes.NewOnDemandProbeListener(a.FlowProbeBundle, a.Graph, captureHandler) if err != nil { logging.GetLogger().Errorf("Unable to start on-demand flow probe %s", err.Error()) os.Exit(1) } a.OnDemandProbeListener = l a.OnDemandProbeListener.Start() } go a.HTTPServer.ListenAndServe() }