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

Function serve

backend/python/kitten-tts/backend.py:78–106  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

76 return backend_pb2.Result(success=True)
77
78def serve(address):
79 server = grpc.server(futures.ThreadPoolExecutor(max_workers=MAX_WORKERS),
80 options=[
81 ('grpc.max_message_length', 50 * 1024 * 1024), # 50MB
82 ('grpc.max_send_message_length', 50 * 1024 * 1024), # 50MB
83 ('grpc.max_receive_message_length', 50 * 1024 * 1024), # 50MB
84 ],
85 interceptors=get_auth_interceptors(),
86 )
87 backend_pb2_grpc.add_BackendServicer_to_server(BackendServicer(), server)
88 server.add_insecure_port(address)
89 server.start()
90 print("Server started. Listening on: " + address, file=sys.stderr)
91
92 # Define the signal handler function
93 def signal_handler(sig, frame):
94 print("Received termination signal. Shutting down...")
95 server.stop(0)
96 sys.exit(0)
97
98 # Set the signal handlers for SIGINT and SIGTERM
99 signal.signal(signal.SIGINT, signal_handler)
100 signal.signal(signal.SIGTERM, signal_handler)
101
102 try:
103 while True:
104 time.sleep(_ONE_DAY_IN_SECONDS)
105 except KeyboardInterrupt:
106 server.stop(0)
107
108if __name__ == "__main__":
109 parser = argparse.ArgumentParser(description="Run the gRPC server.")

Callers 1

backend.pyFile · 0.70

Calls 4

get_auth_interceptorsFunction · 0.90
startMethod · 0.80
signalMethod · 0.80
BackendServicerClass · 0.70

Tested by

no test coverage detected