Skip to content

Commit

Permalink
api: non-zero exit code if MQ engine startup fails (#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpinDale authored Jan 1, 2025
1 parent 92cee43 commit 34cf9b7
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions aphrodite/endpoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def _force_log():

@asynccontextmanager
async def build_engine_client(
args: Namespace) -> AsyncIterator[Optional[EngineClient]]:
args: Namespace) -> AsyncIterator[EngineClient]:

# Context manager to handle engine_client lifecycle
# Ensures everything is shutdown and cleaned up on error/exit
Expand All @@ -126,7 +126,7 @@ async def build_engine_client(
async def build_engine_client_from_engine_args(
engine_args: AsyncEngineArgs,
disable_frontend_multiprocessing: bool = False,
) -> AsyncIterator[Optional[EngineClient]]:
) -> AsyncIterator[EngineClient]:
"""
Create EngineClient, either:
- in-process using the AsyncAphrodite Directly
Expand Down Expand Up @@ -198,10 +198,8 @@ async def build_engine_client_from_engine_args(
break
except TimeoutError:
if not engine_process.is_alive():
logger.error("Engine process died before responding "
"to readiness probe")
yield None
return
raise RuntimeError(
"Engine process failed to start") from None

yield mp_engine_client # type: ignore[misc]
finally:
Expand Down Expand Up @@ -1178,9 +1176,6 @@ def signal_handler(*_) -> None:
signal.signal(signal.SIGTERM, signal_handler)

async with build_engine_client(args) as engine_client:
# If None, creation of the client failed and we exit.
if engine_client is None:
return
app = build_app(args)
model_config = await engine_client.get_model_config()
init_app_state(engine_client, model_config, app.state, args)
Expand Down

0 comments on commit 34cf9b7

Please sign in to comment.