@@ -130,7 +130,6 @@ def __init__(
130130 api_path : str = "/predict" ,
131131 healthcheck_path : str = "/health" ,
132132 info_path : str = "/info" ,
133- shutdown_path : str = "/shutdown" ,
134133 model_metadata : Optional [dict ] = None ,
135134 stream : bool = False ,
136135 spec : Optional [LitSpec ] = None ,
@@ -155,7 +154,6 @@ def __init__(
155154 api_path: URL path for the prediction endpoint.
156155 healthcheck_path: URL path for the health check endpoint.
157156 info_path: URL path for the server and model information endpoint.
158- shutdown_path: URL path for the server shutdown endpoint.
159157 model_metadata: Metadata about the model, shown at the info endpoint.
160158 stream: Whether to enable streaming responses.
161159 spec: Specification for the API, such as OpenAISpec or custom specs.
@@ -222,9 +220,6 @@ def __init__(
222220 "info_path must start with '/'. Please provide a valid api path like '/info', '/details', or '/v1/info'"
223221 )
224222
225- if not shutdown_path .startswith ("/" ):
226- raise ValueError ("shutdown_path must start with '/'. Please provide a valid api path like '/shutdown'" )
227-
228223 try :
229224 json .dumps (model_metadata )
230225 except (TypeError , ValueError ):
@@ -248,7 +243,6 @@ def __init__(
248243 self .api_path = api_path
249244 self .healthcheck_path = healthcheck_path
250245 self .info_path = info_path
251- self .shutdown_path = shutdown_path
252246 self .track_requests = track_requests
253247 self .timeout = timeout
254248 lit_api .stream = stream
@@ -453,16 +447,6 @@ async def info(request: Request) -> Response:
453447 }
454448 )
455449
456- @self .app .post (self .shutdown_path , dependencies = [Depends (self .setup_auth ())])
457- async def shutdown (request : Request ):
458- server = self .app .state .server
459- print ("Initiating shutdown..." )
460- if server .should_exit :
461- return Response (content = "Shutdown already in progress" , status_code = 400 )
462- server .should_exit = True
463-
464- return Response (content = "Server has been shutdown" )
465-
466450 async def predict (request : self .request_type ) -> self .response_type :
467451 self ._callback_runner .trigger_event (
468452 EventTypes .ON_REQUEST .value ,
@@ -633,14 +617,12 @@ def run(
633617 print (f"Uvicorn worker { i } : [{ uw .pid } ]" )
634618 uw .join ()
635619 finally :
620+ print ("Shutting down LitServe" )
636621 self ._transport .close ()
637- print ("Transport closed" )
638622 for iw in inference_workers :
639623 iw : Process
640- print (f"Terminating worker [PID { iw .pid } ]" )
641624 iw .terminate ()
642625 iw .join ()
643- print ("Shutting down LitServe" )
644626 manager .shutdown ()
645627
646628 def _prepare_app_run (self , app : FastAPI ):
@@ -669,7 +651,6 @@ def _start_server(self, port, num_uvicorn_servers, log_level, sockets, uvicorn_w
669651 # https://github.com/encode/uvicorn/pull/802
670652 config .workers = num_uvicorn_servers
671653 server = uvicorn .Server (config = config )
672- self .app .state .server = server
673654 if uvicorn_worker_type == "process" :
674655 ctx = mp .get_context ("fork" )
675656 w = ctx .Process (target = server .run , args = (sockets ,))
0 commit comments