package main import ( "context" "flag" "fmt" "log" "net" pb "deevirt.fr/compute/cmd/compute_mgr/proto" "deevirt.fr/compute/cmd/compute_mgr/server/raft" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) var ( myAddr = flag.String("address", "localhost:60051", "TCP host+port for this node") raftId = flag.String("raft_id", "", "Node id used by Raft") ) func main() { flag.Parse() if *raftId == "" { log.Fatalf("flag --raft_id is required") } ctx := context.Background() _, port, err := net.SplitHostPort(*myAddr) if err != nil { log.Fatalf("failed to parse local address (%q): %v", *myAddr, err) } sock, err := net.Listen("tcp", fmt.Sprintf(":%s", port)) if err != nil { log.Fatalf("failed to listen: %v", err) } r, tm, err := raft.NewRaft(ctx, *raftId, *myAddr) if err != nil { log.Fatalf("failed to start raft: %v", err) } s := grpc.NewServer() pb.RegisterDomainServer(s, nil) tm.Register(s) //leaderhealth.Setup(r, s, []string{"Example"}) raft.Register(s, r) reflection.Register(s) if err := s.Serve(sock); err != nil { log.Fatalf("failed to serve: %v", err) } }