uvicorn allow setting num workers (#7681)

This commit is contained in:
Ishaan Jaff 2025-01-10 19:03:14 -08:00 committed by GitHub
parent 5c870c0c51
commit 9ac18caf24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,7 +68,7 @@ def is_port_in_use(port):
@click.option( @click.option(
"--num_workers", "--num_workers",
default=1, default=1,
help="Number of gunicorn workers to spin up", help="Number of uvicorn / gunicorn workers to spin up. By default, 1 uvicorn is used.",
envvar="NUM_WORKERS", envvar="NUM_WORKERS",
) )
@click.option("--api_base", default=None, help="API base URL.") @click.option("--api_base", default=None, help="API base URL.")
@ -653,7 +653,7 @@ def run_server( # noqa: PLR0915
from litellm.proxy.proxy_server import app # noqa from litellm.proxy.proxy_server import app # noqa
uvicorn_args = { uvicorn_args = {
"app": app, "app": "litellm.proxy.proxy_server:app",
"host": host, "host": host,
"port": port, "port": port,
} }
@ -674,6 +674,7 @@ def run_server( # noqa: PLR0915
uvicorn.run( uvicorn.run(
**uvicorn_args, **uvicorn_args,
loop="uvloop", loop="uvloop",
workers=num_workers,
) )
elif run_gunicorn is True: elif run_gunicorn is True:
# Gunicorn Application Class # Gunicorn Application Class