MCPcopy
hub / github.com/grpc/grpc-go / main

Function main

benchmark/worker/main.go:204–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

202}
203
204func main() {
205 grpc.EnableTracing = false
206
207 flag.Parse()
208 lis, err := net.Listen("tcp", ":"+strconv.Itoa(*driverPort))
209 if err != nil {
210 logger.Fatalf("failed to listen: %v", err)
211 }
212 logger.Infof("worker listening at port %v", *driverPort)
213
214 s := grpc.NewServer()
215 stop := make(chan bool)
216 testgrpc.RegisterWorkerServiceServer(s, &workerServer{
217 stop: stop,
218 serverPort: *serverPort,
219 })
220
221 go func() {
222 <-stop
223 // Wait for 1 second before stopping the server to make sure the return value of QuitWorker is sent to client.
224 // TODO revise this once server graceful stop is supported in gRPC.
225 time.Sleep(time.Second)
226 s.Stop()
227 }()
228
229 runtime.SetBlockProfileRate(*blockProfRate)
230
231 if *pprofPort >= 0 {
232 go func() {
233 logger.Infoln("Starting pprof server on port " + strconv.Itoa(*pprofPort))
234 logger.Infoln(http.ListenAndServe("localhost:"+strconv.Itoa(*pprofPort), nil))
235 }()
236 }
237
238 s.Serve(lis)
239}

Callers

nothing calls this directly

Calls 7

StopMethod · 0.95
ServeMethod · 0.95
NewServerFunction · 0.92
ParseMethod · 0.65
FatalfMethod · 0.65
InfofMethod · 0.65
InfolnMethod · 0.65

Tested by

no test coverage detected