async def main(): server = Server([LEDService()]) with graceful_exit([server]): await server.start(sys.argv[1], "5001") print(f"Server running on {sys.argv[1]}") await server.wait_closed()
async def start(): server = Server(handlers) with graceful_exit([server]): await server.start(host, port) print(f"Serving on {host}:{port}") await server.wait_closed()
async def serve() -> None: host = os.environ.get("GRPC_HOST", "0.0.0.0") port = int(os.environ.get("GRPC_PORT", "50051")) debug = os.environ.get("DEBUG", "FALSE").upper() == "TRUE" if not debug: matplotlib.use("agg") log = configure_logger() log.info("creating resources") resources = Resources() service = server.Server([StalkReporter(resources, debug)]) log.info("starting up service") with utils.graceful_exit([service]): await service.start(host, port) log.info(f"serving grpc on {host}:{port}") await service.wait_closed() log.info("shutting down service") log.info("service shutdown complete") log.info("releasing resource") await resources.shutdown() log.info("shutdown complete")
async def main(*, host='127.0.0.1', port=50051): loop = asyncio.get_running_loop() server = Server([Greeter()], loop=loop) with graceful_exit([server], loop=loop): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main(*, host: str = '127.0.0.1', port: int = 50051) -> None: server = Server([Greeter()]) # Note: graceful_exit isn't supported in Windows with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main(*, host: str = '127.0.0.1', port: int = 50051) -> None: with ProcessPoolExecutor(max_workers=4) as executor: server = Server([Primes(executor)]) with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main(*, host: str = '127.0.0.1', port: int = 50051) -> None: server = Server([Greeter()]) listen(server, RecvRequest, on_recv_request) with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main(*, host='127.0.0.1', port=50051): await cf.initialize() services = ServerReflection.extend([APIService()]) server = Server(services) with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main(*, host: str = '127.0.0.1', port: int = 50051) -> None: services = ServerReflection.extend([Greeter()]) server = Server(services) with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def start_server(socket, *a, **k): "Coroutine to bring up the rpc server" server = Server([PoreRefinerDispatchServer()]) with graceful_exit([server]): await server.start(path=str(socket)) log.info(f"RPC server listening on {socket}...") await server.wait_closed() log.warning(f"RPC server shutting down.")
async def main(*, host='127.0.0.1', port=50051): await db.set_bind('postgresql://*****:*****@localhost/book_shop') await db.gino.create_all() server = Server([BookService()]) with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def serve(bind_address='0.0.0.0', port=57850): logger.debug('Create gRPC server') server = Server([TelemetryReceiver()]) with graceful_exit([server]): await server.start(bind_address, port) logger.debug('serving on %s:%d', bind_address, port) await server.wait_closed()
async def serve( self, host: str = 'localhost', port: int = 50000, ): with graceful_exit([self.server]): await self.server.start(host, port) logger.debug(f'Serving on {host}:{port}') await self.server.wait_closed()
async def run_server(*, provider: schemas.Provider): if os.getenv(settings.MAGIC_COOKIE_KEY) != settings.MAGIC_COOKIE_VALUE: logger.error("This is a Terraform plugin. " "These are not meant to be executed directly.") sys.exit(1) min_port = int(os.getenv("PLUGIN_MIN_PORT") or 0) max_port = int(os.getenv("PLUGIN_MAX_PORT") or 0) if min_port > max_port: logger.error( "PLUGIN_MIN_PORT value is greater than PLUGIN_MAX_PORT value") sys.exit(1) certificate_data = utils.generate_certificate() with contextlib.ExitStack() as stack: keyfile = stack.enter_context(tempfile.NamedTemporaryFile()) keyfile.write(utils.encode_private_key(certificate_data.private_key)) keyfile.flush() certfile = stack.enter_context(tempfile.NamedTemporaryFile()) certfile.write( utils.encode_certificate_pem(certificate_data.certificate)) certfile.flush() client_cert = os.getenv("PLUGIN_CLIENT_CERT") ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) ctx.verify_mode = ssl.CERT_REQUIRED ctx.minimum_version = ssl.TLSVersion.TLSv1_2 ctx.load_cert_chain(certfile=certfile.name, keyfile=keyfile.name) ctx.load_verify_locations(cadata=client_cert) shutdown_event = asyncio.Event() handlers = [ GRPCController(shutdown_event=shutdown_event), GRPCStdio(), ProviderService(provider=provider, shutdown_event=shutdown_event), ] server = grpclib.server.Server(handlers) with graceful_exit([server]): port = min_port while port <= max_port: try: await server.start("127.0.0.1", port, ssl=ctx) except OSError: port += 1 else: break await write_handshake_response( file=sys.stdout, protocol_version=settings.PROTOCOL_VERSION, port=port, certificate=certificate_data.certificate, ) await wait_shutdown_event(server=server, shutdown_event=shutdown_event) await server.wait_closed()
async def server(host="127.0.0.1", port=50051): services = [FilterVisualizer()] services = ServerReflection.extend(services) print(services) server = Server(services) with graceful_exit([server]): await server.start(host, port) print(f"Serving on {host}:{port}") await client()
async def main(self, app_cls, app_args): address = app_args.get("address") server = Server([app_cls(app_args)]) host, port = address.split(":") logger.debug(f"Starting server on host {host} : port {port}") with graceful_exit([server]): await server.start(host, port) await server.wait_closed()
async def main(*, host='0.0.0.0', port=Config['port']): # 起协程监听kafka消费 # loop = asyncio.get_event_loop() # tasks = asyncio.gather(coroutine) # loop.run_until_complete(tasks) # server = Server(services.GeneralServices()) with graceful_exit([server]): await server.start(host, port) print(f'grpcServer serving on {host}:{port}') await server.wait_closed()
async def main(options): ib = IB() ib.disconnectedEvent += onDisconnected await ib.connectAsync(options.ib_host, options.ib_port) server = Server([IbBridgeServer(ib)]) with graceful_exit([server]): await server.start(options.http_host, options.http_port) print(f"Serving on {options.http_host}:{options.http_port}") await server.wait_closed() ib.disconnectedEvent -= onDisconnected ib.disconnect()
async def main(*, host: str = '0.0.0.0', port: int = 50051) -> None: server = Server([Health()]) with graceful_exit([server]): await server.start(host, port, ssl=create_secure_context( SERVER_CERT, SERVER_KEY, trusted=CLIENT_CERT, )) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main( *, host: str = "127.0.0.1", port: int = int(os.environ.get("PORT", 65420)) ) -> None: server = Server([AddressBook()]) with graceful_exit([server]): await server.start(host, port) print(f"Serving on {host}:{port}") await server.wait_closed() database.connection.close() print("Terminated")
async def process_messages(self): with open(self.config.nats_subjects_file) as json_file: subjects = json.load(json_file) self.logger.info(f"Loaded NATS subject file: {subjects}") self.logger.info(f"Creating entrypoint service") entrypoint = Entrypoint(self.logger, self.nc, subjects, self.config) services = ServerReflection.extend([entrypoint]) server = Server(services) with graceful_exit([server]): await server.start(self.host, self.port) self.logger.info(f'Serving gPRC server on {self.host}:{self.port}') await server.wait_closed()
async def main(): if not path.isfile(DB_PATH): create_database(DB_PATH) db_connection = sqlite3.connect(DB_PATH) category_service = services.CategoryService( repositories.CategoryRepository(db_connection)) server = Server([category_service]) with graceful_exit([server]): await server.start(HOST, PORT) print(f"Serving on {HOST}:{PORT}") await server.wait_closed() db_connection.commit() db_connection.close()
async def main(): server = Server([MyService()]) server_started_event = asyncio.Event() asyncio.create_task( create_client(server_started_event) ) with graceful_exit([server]): await server.start( host=HOST, port=PORT, ) server_started_event.set() print(f'Serving on {HOST}:{PORT}') await server.wait_closed()
async def main( screen_type: str, *, host: str, port: int, threads: int, log_level: str, asyncio_log_level: Optional[str], ): print("A very SLO movie player") core_logger = logging.getLogger("qcmd.core") core_logger.setLevel(log_level) if asyncio_log_level: aio_logger = logging.getLogger("asyncio") aio_logger.setLevel(asyncio_log_level) with ThreadPoolExecutor(threads, thread_name_prefix="Server") as tpe: with video.VideoProcessorFactory(tpe, None) as vph, disp.create( screen_type, tpe) as dph: dph.send(dcmd.INIT_SCREEN, pri=10).or_err(lambda ex, t: print(ex, ex.__class__)) dph.send(dcmd.CLEAR, pri=45) dph.join() player = PlayerService(dph, vph) server = Server([player]) with graceful_exit([server]): print("SERVING:", f"""{host}:{port}""") await server.start(host=host, port=port) await server.wait_closed() vph.halt() dph.join() dph.send(dcmd.SLEEP) dph.join() return None
async def main(*, host='127.0.0.1', port=50051): client = MPDClient() await client.connect('localhost', 6600) print(f'mpd version: {client.mpd_version}') queue = asyncio.Queue() commands_queue = asyncio.Queue() task1 = asyncio.create_task(worker(queue)) # TODO: remove task2 = asyncio.create_task(notifier(client, commands_queue)) server = Server([WallboxApi(commands_queue, queue, client)]) with graceful_exit([server]): await server.start(host, port) await server.wait_closed() task1.cancel() task2.cancel() client.disconnect()
async def main(self): """Uses grpclibs to create an async grpc service for App, then run the App_cls [Player, Manager, Agent, Monitor, Infra] with passed params (app_args) Starts server on specified address:port and wait to be closed by grpclibs graceful_exit OBS: Adds App role to app_args (so Core and Status classes make proper init) """ app_args = self.cfg.get() address = app_args.get("address") host, port = address.split(":") logger.debug(f"App serving on host:port {host}:{port}") if self.app_cls and self.app_role: app_args["role"] = self.app_role server = Server([self.app_cls(app_args)]) with graceful_exit([server]): await server.start(host, port) await server.wait_closed() else: logger.info(f"Neither app_cls or app_role were defined" f"{self.app_cls} and/or {self.app_role}")
async def main(*, host='127.0.0.1', port=50051): server = Server([S3()]) with graceful_exit([server]): await server.start(host, port) print(f'Serving on {host}:{port}') await server.wait_closed()
async def main(host: str = "127.0.0.1", port: int = 50051) -> None: server = Server([Greeter()]) with graceful_exit([server]): await server.start(host, port) print(f"Serving on {host}:{port}") await server.wait_closed()
async def serve(batch_size): server = Server([DataStreamer(batch_size)]) with graceful_exit([server]): await server.start("0.0.0.0", 50051) logging.info(f"starting server on 0.0.0.0:50051") await server.wait_closed()
async def start_grpc_server(loop, host="0.0.0.0", port=5000): server = Server([AioShadowsocksServicer()], loop=loop) with graceful_exit([server], loop=loop): await server.start(host, port) logging.info(f"Start Grpc Server on {host}:{port}") await server.wait_closed()