def run(self):
self.start_server(self.outer_server, '[::]:' + str(self.__port))
# Bind Only loopback address (ip4) - TODO IP6
self.start_server(self.inner_server, conf.INNER_SERVER_BIND_IP + ':' + str(self.__inner_service_port))
# Block Generator ? subscribe ?? ?? Block Generator ? peer ? channel ??? ????.
# ??? peer ? gRPC ??? ??? ??? ? Block Generator ? subscribe ??? ??? ??.
time.sleep(conf.WAIT_GRPC_SERVICE_START)
try:
while self.is_run():
self.__run_loop_functions()
time.sleep(conf.SLEEP_SECONDS_IN_SERVICE_NONE)
except KeyboardInterrupt:
logging.info("Server Stop by KeyboardInterrupt")
finally:
while not self.__subscriptions.empty():
channel, subscribe_stub = self.__subscriptions.get()
logging.info(f"Un subscribe to channel({channel}) server({subscribe_stub.target})")
self.__un_subscribe(channel, self.__port, subscribe_stub)
self.__stop_broadcast_process()
if self.__inner_service_port is not None:
self.inner_server.stop(0)
self.outer_server.stop(0)
logging.info("Server thread Ended.")
评论列表
文章目录