def run(self, conn, event: multiprocessing.Event): logging.debug("RestService run...") args = ['python3', '-m', 'loopchain', 'rest', '-p', str(self._port)] args += command_arguments.get_raw_commands_by_filter( command_arguments.Type.AMQPKey, command_arguments.Type.RadioStationTarget ) server = CommonSubprocess(args) api_port = self._port + conf.PORT_DIFF_REST_SERVICE_CONTAINER server.set_proctitle(f"{setproctitle.getproctitle()} RestServer api_port({api_port})") logging.info(f'RestService run complete port {api_port}') # complete init event.set() command = None while command != "quit": try: command, param = conn.recv() logging.debug(f"RestService got: {param}") except Exception as e: logging.warning(f"RestService conn.recv() error: {e}") except KeyboardInterrupt: pass server.stop() logging.info("RestService Ended.")
def run(self, conn, event: multiprocessing.Event): logging.debug("Container run...") if self._type == ServerType.GRPC: logging.info(f'Container run grpc port {self._port}') setproctitle.setproctitle(f"{setproctitle.getproctitle()} {self._process_name}") server = grpc.server(futures.ThreadPoolExecutor(conf.MAX_WORKERS, "ContainerThread")) loopchain_pb2_grpc.add_ContainerServicer_to_server(self, server) GRPCHelper().add_server_port(server, '[::]:' + str(self._port), conf.SSLAuthType.none) logging.info(f'Container run complete grpc port {self._port}') elif self._type == ServerType.REST_PEER: args = ['python3', '-m', 'loopchain', 'rest', '-p', str(self._port)] args += command_arguments.get_raw_commands_by_filter( command_arguments.Type.AMQPTarget, command_arguments.Type.AMQPKey, command_arguments.Type.Develop, command_arguments.Type.ConfigurationFilePath, command_arguments.Type.RadioStationTarget ) server = CommonSubprocess(args) api_port = self._port + conf.PORT_DIFF_REST_SERVICE_CONTAINER server.set_proctitle(f"{setproctitle.getproctitle()} RestServer api_port({api_port})") else: args = ['python3', '-m', 'loopchain', 'rest-rs', '-p', str(self._port)] args += command_arguments.get_raw_commands_by_filter( command_arguments.Type.Develop, command_arguments.Type.ConfigurationFilePath ) api_port = self._port + conf.PORT_DIFF_REST_SERVICE_CONTAINER server = CommonSubprocess(args) server.set_proctitle(f"{setproctitle.getproctitle()} RestServerRS api_port({api_port})") logging.info(f'Container run complete port {self._port}') # complete init event.set() if self._type == ServerType.GRPC: self._append_monitor() command = None while command != "quit": try: command, param = conn.recv() # Queue 에 내용이 들어올 때까지 여기서 대기 된다. 따라서 Sleep 이 필요 없다. logging.debug("Container got: " + str(param)) except Exception as e: logging.warning("Container conn.recv() error: " + str(e)) except KeyboardInterrupt: pass if self._type == ServerType.GRPC: server.stop(0) else: server.stop() logging.info("Server Container Ended.")
def run(self, conn, event: multiprocessing.Event): logging.debug("Container run...") if self._type == ServerType.REST_PEER: args = ['python3', '-m', 'loopchain', 'rest', '-p', str(self._port)] args += command_arguments.get_raw_commands_by_filter( command_arguments.Type.AMQPTarget, command_arguments.Type.AMQPKey, command_arguments.Type.Develop, command_arguments.Type.ConfigurationFilePath, command_arguments.Type.RadioStationTarget ) server = CommonSubprocess(args) api_port = self._port + conf.PORT_DIFF_REST_SERVICE_CONTAINER server.set_proctitle(f"{setproctitle.getproctitle()} RestServer api_port({api_port})") else: args = ['python3', '-m', 'loopchain', 'rest-rs', '-p', str(self._port)] args += command_arguments.get_raw_commands_by_filter( command_arguments.Type.Develop, command_arguments.Type.ConfigurationFilePath ) api_port = self._port + conf.PORT_DIFF_REST_SERVICE_CONTAINER server = CommonSubprocess(args) server.set_proctitle(f"{setproctitle.getproctitle()} RestServerRS api_port({api_port})") logging.info(f'Container run complete port {self._port}') # complete init event.set() command = None while command != "quit": try: command, param = conn.recv() # Queue 에 내용이 들어올 때까지 여기서 대기 된다. 따라서 Sleep 이 필요 없다. logging.debug("Container got: " + str(param)) except Exception as e: logging.warning("Container conn.recv() error: " + str(e)) except KeyboardInterrupt: pass server.stop() logging.info("Server Container Ended.")