mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Allow specifying the service address.
This will be useful for testing in different environment, e.g. emulator v.s. phone where multiple ethernet interface might be available and we need to explicitly pick an interface to start the server. Test: Manual test Bug: None Change-Id: I3c046e9549225058178346f529773cffa841ce07
This commit is contained in:
@@ -28,20 +28,23 @@ using ::grpc::Server;
|
||||
using ::grpc::ServerBuilder;
|
||||
using ::grpc::ServerWriter;
|
||||
|
||||
void RunServer() {
|
||||
std::string serverAddress(GRPC_SERVICE_ADDRESS);
|
||||
void RunServer(const std::string& serviceAddr) {
|
||||
std::shared_ptr<TestWakeupClientServiceImpl> service =
|
||||
std::make_unique<TestWakeupClientServiceImpl>();
|
||||
|
||||
ServerBuilder builder;
|
||||
builder.AddListeningPort(serverAddress, grpc::InsecureServerCredentials());
|
||||
builder.AddListeningPort(serviceAddr, grpc::InsecureServerCredentials());
|
||||
builder.RegisterService(service.get());
|
||||
std::unique_ptr<Server> server(builder.BuildAndStart());
|
||||
printf("Test Remote Access GRPC Server listening on %s\n", serverAddress.c_str());
|
||||
printf("Test Remote Access GRPC Server listening on %s\n", serviceAddr.c_str());
|
||||
server->Wait();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
RunServer();
|
||||
std::string serviceAddr = GRPC_SERVICE_ADDRESS;
|
||||
if (argc > 1) {
|
||||
serviceAddr = argv[1];
|
||||
}
|
||||
RunServer(serviceAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user