Skip to content

Commit

Permalink
feat: 程序抛异常时,将异常打印日志
Browse files Browse the repository at this point in the history
  • Loading branch information
jimpang committed Aug 8, 2024
1 parent b2fc66b commit 8569f29
Showing 1 changed file with 34 additions and 31 deletions.
65 changes: 34 additions & 31 deletions vllm/entrypoints/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import asyncio
import json
import ssl
from dataclasses import asdict
from typing import AsyncGenerator
from argparse import Namespace
from dataclasses import asdict
from typing import Any, AsyncGenerator, Optional

from fastapi import FastAPI, Request
Expand All @@ -19,8 +18,8 @@
from vllm.engine.arg_utils import AsyncEngineArgs
from vllm.engine.async_llm_engine import AsyncLLMEngine
from vllm.entrypoints.launcher import serve_http
from vllm.logger import init_logger
from vllm.inputs import TokensPrompt
from vllm.logger import init_logger
from vllm.lora.request import LoRARequest
from vllm.sampling_params import SamplingParams
from vllm.usage.usage_lib import UsageContext
Expand Down Expand Up @@ -115,8 +114,8 @@ def build_app(args: Namespace) -> FastAPI:


async def init_app(
args: Namespace,
llm_engine: Optional[AsyncLLMEngine] = None,
args: Namespace,
llm_engine: Optional[AsyncLLMEngine] = None,
) -> FastAPI:
app = build_app(args)

Expand All @@ -125,7 +124,7 @@ async def init_app(
engine_args = AsyncEngineArgs.from_cli_args(args)
engine = (llm_engine
if llm_engine is not None else AsyncLLMEngine.from_engine_args(
engine_args, usage_context=UsageContext.API_SERVER))
engine_args, usage_context=UsageContext.API_SERVER))

return app

Expand Down Expand Up @@ -155,28 +154,32 @@ async def run_server(args: Namespace,


if __name__ == "__main__":
parser = FlexibleArgumentParser()
parser.add_argument("--host", type=str, default=None)
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--ssl-keyfile", type=str, default=None)
parser.add_argument("--ssl-certfile", type=str, default=None)
parser.add_argument("--ssl-ca-certs",
type=str,
default=None,
help="The CA certificates file")
parser.add_argument(
"--ssl-cert-reqs",
type=int,
default=int(ssl.CERT_NONE),
help="Whether client certificate is required (see stdlib ssl module's)"
)
parser.add_argument(
"--root-path",
type=str,
default=None,
help="FastAPI root_path when app is behind a path based routing proxy")
parser.add_argument("--log-level", type=str, default="debug")
parser = AsyncEngineArgs.add_cli_args(parser)
args = parser.parse_args()

asyncio.run(run_server(args))
try:
parser = FlexibleArgumentParser()
parser.add_argument("--host", type=str, default=None)
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--ssl-keyfile", type=str, default=None)
parser.add_argument("--ssl-certfile", type=str, default=None)
parser.add_argument("--ssl-ca-certs",
type=str,
default=None,
help="The CA certificates file")
parser.add_argument(
"--ssl-cert-reqs",
type=int,
default=int(ssl.CERT_NONE),
help="Whether client certificate is required (see stdlib ssl module's)"
)
parser.add_argument(
"--root-path",
type=str,
default=None,
help="FastAPI root_path when app is behind a path based routing proxy")
parser.add_argument("--log-level", type=str, default="debug")
parser = AsyncEngineArgs.add_cli_args(parser)
args = parser.parse_args()

asyncio.run(run_server(args))
except Exception as e:
logger.error(str(e))
raise

0 comments on commit 8569f29

Please sign in to comment.