Skip to content

Commit

Permalink
move run grpc to setup grpc
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sharma <[email protected]>
  • Loading branch information
yashrsharma44 committed May 21, 2021
1 parent a12006c commit 4be0b7b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ func runReceive(
if err := setupGRPCServer(g, logger, reg, tracer, conf, s, startGRPCListening, reloadGRPCServer, comp, dbs, webHandler, grpcLogOpts, tagOpts, grpcProbe); err != nil {
return err
}
if err := runGRPCServer(g, logger, s, startGRPCListening, conf); err != nil {
return err
}
// if err := runGRPCServer(g, logger, s, startGRPCListening, conf); err != nil {
// return err
// }
}

level.Debug(logger).Log("msg", "setting up receive http handler")
Expand Down Expand Up @@ -357,6 +357,18 @@ func setupGRPCServer(g *run.Group,
return nil
}, func(error) {})

// We need to be able to start and stop the gRPC server
// whenever the DB changes, thus it needs its own run group.
g.Add(func() error {
for range startGRPCListening {
level.Info(logger).Log("msg", "listening for StoreAPI and WritableStoreAPI gRPC", "address", *conf.grpcBindAddr)
if err := s.ListenAndServe(); err != nil {
return errors.Wrap(err, "serve gRPC")
}
}
return nil
}, func(error) {})

return nil

}
Expand Down

0 comments on commit 4be0b7b

Please sign in to comment.