Skip to content

Commit

Permalink
feat(cli): reload option for start-http-server (#4916)
Browse files Browse the repository at this point in the history
* feat: reload option for start-http-server

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming authored Aug 13, 2024
1 parent 408ef26 commit 5621a23
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bentoml_cli/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def cli():
default=None,
help="Maximum number of seconds to wait for graceful shutdown. After this timeout, the server will start terminating requests.",
)
@click.option(
"--reload",
is_flag=True,
help="Reload Service when code changes detected",
default=False,
)
@add_experimental_docstring
def start_http_server( # type: ignore (unused warning)
bento: str,
Expand All @@ -139,6 +145,7 @@ def start_http_server( # type: ignore (unused warning)
ssl_ciphers: str | None,
timeout_keep_alive: int | None,
timeout_graceful_shutdown: int | None,
reload: bool = False,
) -> None:
"""
Start a HTTP API server standalone. This will be used inside Yatai.
Expand Down Expand Up @@ -168,6 +175,8 @@ def start_http_server( # type: ignore (unused warning)

svc = load(bento, working_dir=working_dir)
if isinstance(svc, Service):
if reload:
logger.warning("--reload does not work with legacy style services")
# for <1.2 bentos
if not service_name or service_name == svc.name:
from bentoml.start import start_http_server
Expand Down Expand Up @@ -234,6 +243,7 @@ def start_http_server( # type: ignore (unused warning)
timeout_graceful_shutdown=timeout_graceful_shutdown,
dependency_map=runner_map_dict,
service_name=service_name,
reload=reload,
)

@cli.command(hidden=True)
Expand Down

0 comments on commit 5621a23

Please sign in to comment.