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

Function serve

backend/python/fish-speech/backend.py:423–453  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

421
422
423def serve(address):
424 server = grpc.server(
425 futures.ThreadPoolExecutor(max_workers=MAX_WORKERS),
426 options=[
427 ("grpc.max_message_length", 50 * 1024 * 1024), # 50MB
428 ("grpc.max_send_message_length", 50 * 1024 * 1024), # 50MB
429 ("grpc.max_receive_message_length", 50 * 1024 * 1024), # 50MB
430 ],
431
432 interceptors=get_auth_interceptors(),
433 )
434 backend_pb2_grpc.add_BackendServicer_to_server(BackendServicer(), server)
435 server.add_insecure_port(address)
436 server.start()
437 print("Server started. Listening on: " + address, file=sys.stderr)
438
439 # Define the signal handler function
440 def signal_handler(sig, frame):
441 print("Received termination signal. Shutting down...")
442 server.stop(0)
443 sys.exit(0)
444
445 # Set the signal handlers for SIGINT and SIGTERM
446 signal.signal(signal.SIGINT, signal_handler)
447 signal.signal(signal.SIGTERM, signal_handler)
448
449 try:
450 while True:
451 time.sleep(_ONE_DAY_IN_SECONDS)
452 except KeyboardInterrupt:
453 server.stop(0)
454
455
456if __name__ == "__main__":

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