RunServer initializes a tcp server on port which listens to requests from other workers for pb.communication.
(bindall bool)
| 92 | // RunServer initializes a tcp server on port which listens to requests from |
| 93 | // other workers for pb.communication. |
| 94 | func RunServer(bindall bool) { |
| 95 | laddr := "localhost" |
| 96 | if bindall { |
| 97 | laddr = "0.0.0.0" |
| 98 | } |
| 99 | ln, err := net.Listen("tcp", fmt.Sprintf("%s:%d", laddr, workerPort())) |
| 100 | if err != nil { |
| 101 | log.Fatalf("While running server: %v", err) |
| 102 | } |
| 103 | glog.Infof("Worker listening at address: %v", ln.Addr()) |
| 104 | |
| 105 | pb.RegisterWorkerServer(workerServer, &grpcWorker{}) |
| 106 | pb.RegisterRaftServer(workerServer, &raftServer) |
| 107 | if err := workerServer.Serve(ln); err != nil { |
| 108 | glog.Errorf("Error while calling Serve: %+v", err) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | // StoreStats returns stats for data store. |
| 113 | func StoreStats() string { |
no test coverage detected