MCPcopy
hub / github.com/mudler/LocalAI / serve

Function serve

backend/python/vllm/backend.py:895–921  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

893 return None
894
895async def serve(address):
896 # Start asyncio gRPC server
897 server = grpc.aio.server(migration_thread_pool=futures.ThreadPoolExecutor(max_workers=MAX_WORKERS),
898 options=[
899 ('grpc.max_message_length', 50 * 1024 * 1024), # 50MB
900 ('grpc.max_send_message_length', 50 * 1024 * 1024), # 50MB
901 ('grpc.max_receive_message_length', 50 * 1024 * 1024), # 50MB
902 ],
903 interceptors=get_auth_interceptors(aio=True),
904 )
905 # Add the servicer to the server
906 backend_pb2_grpc.add_BackendServicer_to_server(BackendServicer(), server)
907 # Bind the server to the address
908 server.add_insecure_port(address)
909
910 # Gracefully shutdown the server on SIGTERM or SIGINT
911 loop = asyncio.get_event_loop()
912 for sig in (signal.SIGINT, signal.SIGTERM):
913 loop.add_signal_handler(
914 sig, lambda: asyncio.ensure_future(server.stop(5))
915 )
916
917 # Start the server
918 await server.start()
919 print("Server started. Listening on: " + address, file=sys.stderr)
920 # Wait for the server to be terminated
921 await server.wait_for_termination()
922
923if __name__ == "__main__":
924 parser = argparse.ArgumentParser(description="Run the gRPC server.")

Callers 1

backend.pyFile · 0.70

Calls 3

get_auth_interceptorsFunction · 0.90
startMethod · 0.80
BackendServicerClass · 0.70

Tested by

no test coverage detected