func main() { cfg := flag.String("c", "cfg.json", "specify config file") version := flag.Bool("v", false, "show version") versionGit := flag.Bool("vg", false, "show version and git commit log") flag.Parse() if *version { fmt.Println(g.VERSION) os.Exit(0) } if *versionGit { fmt.Println(g.VERSION, g.COMMIT) os.Exit(0) } // config g.ParseConfig(*cfg) gconf := g.Config() // proc proc.Start() // graph graph.Start() grpcMsg := make(chan string) if gconf.Grpc.Enabled { // grpc go grpc.Start(grpcMsg) } ginMsg := make(chan string) if gconf.GinHttp.Enabled { //lambdaSetup database.Init() conf.ReadConf("./conf/lambdaSetup.json") go ginHttp.StartWeb(ginMsg) } httpMsg := make(chan string) if gconf.Http.Enabled { // http go http.Start(httpMsg) } select { case <-grpcMsg: log.Printf("%v is crashed", grpcMsg) case <-ginMsg: log.Printf("%v is crashed", ginMsg) case <-httpMsg: log.Printf("%v is crashed", ginMsg) } }
func EndpointQuery() (endpointList []string) { database.Init() db := database.DBConn() gconf := g.Config() var enps []Endpoint var sqlStr string if gconf.GraphDB.Limit == -1 { sqlStr = "SELECT * from graph.endpoint" } else { sqlStr = fmt.Sprintf("SELECT * from graph.endpoint limit %v", gconf.GraphDB.Limit) } db.Raw(sqlStr).Scan(&enps) if len(enps) != 0 { for _, host := range enps { endpointList = append(endpointList, host.Endpoint) } } return }