Commits
Darrell Schiebel authored 9031d784959
91 91 | |
92 92 | public: |
93 93 | grpcRegistrar( Registrar *r ) : registry(r) { } |
94 94 | |
95 95 | }; |
96 96 | |
97 97 | struct grpcState { |
98 98 | std::unique_ptr<Server> server; |
99 99 | std::unique_ptr<grpcRegistrar> reg; |
100 100 | ~grpcState( ) { |
101 - | fprintf(stdout, "stopping registry\n"); |
101 + | if (getenv("GRPC_DEBUG")) fprintf(stdout, "stopping registry\n"); |
102 102 | fflush(stdout); |
103 103 | if ( server ) server->Shutdown( ); |
104 104 | } |
105 105 | }; |
106 106 | |
107 107 | |
108 108 | |
109 109 | |
110 110 | |
111 111 | Registrar::Registrar( ) { |
125 125 | builder.AddListeningPort(server_address, grpc::InsecureServerCredentials(), &selected_port); |
126 126 | // Register "service" as the instance through which we'll communicate with |
127 127 | // clients. In this case it corresponds to an *synchronous* service. |
128 128 | builder.RegisterService(state->reg.get( )); |
129 129 | // Finally assemble the server. |
130 130 | state->server = builder.BuildAndStart( ); |
131 131 | if ( selected_port > 0 ) { |
132 132 | // if an available port can be found, selected_port is set to a value greater than zero |
133 133 | snprintf(address_buf,sizeof(address_buf),address_template,selected_port); |
134 134 | uri_ = address_buf; |
135 - | std::cout << "registry available at " << uri_ << std::endl; |
135 + | if (getenv("GRPC_DEBUG")) std::cout << "registry available at " << uri_ << std::endl; |
136 136 | grpc_state = (void*) state; |
137 137 | } else delete state; |
138 138 | |
139 139 | |
140 140 | } |
141 141 | |
142 142 | Registrar::~Registrar( ) { |
143 143 | |
144 144 | if ( grpc_state ) delete (grpcState*) grpc_state; |
145 145 | |