diff --git a/python/ray/serve/scripts.py b/python/ray/serve/scripts.py new file mode 100644 index 000000000..8a0baa7c0 --- /dev/null +++ b/python/ray/serve/scripts.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import click + +import ray +from ray import serve +from ray.serve.constants import DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT + + +@click.group( + help="[EXPERIMENTAL] CLI for managing Serve instances on a Ray cluster.") +@click.option( + "--address", + "-a", + default="auto", + required=False, + type=str, + help="Address of the running Ray cluster to connect to. " + "Defaults to \"auto\".") +def cli(address): + ray.init(address=address) + + +@cli.command(help="Start a detached Serve instance on the Ray cluster.") +@click.option( + "--http-host", + default=DEFAULT_HTTP_HOST, + required=False, + type=str, + help="Host for HTTP servers to listen on. " + f"Defaults to {DEFAULT_HTTP_HOST}.") +@click.option( + "--http-port", + default=DEFAULT_HTTP_PORT, + required=False, + type=int, + help="Port for HTTP servers to listen on. " + f"Defaults to {DEFAULT_HTTP_PORT}.") +def start(http_host, http_port): + serve.start(detached=True, http_host=http_host, http_port=http_port) + + +@cli.command(help="Shutdown the running Serve instance on the Ray cluster.") +def shutdown(): + serve.connect().shutdown() diff --git a/python/setup.py b/python/setup.py index 7069f57e9..b0e9e1407 100644 --- a/python/setup.py +++ b/python/setup.py @@ -449,8 +449,10 @@ setuptools.setup( entry_points={ "console_scripts": [ "ray=ray.scripts.scripts:main", - "rllib=ray.rllib.scripts:cli [rllib]", "tune=ray.tune.scripts:cli", - "ray-operator=ray.operator:main" + "rllib=ray.rllib.scripts:cli [rllib]", + "tune=ray.tune.scripts:cli", + "ray-operator=ray.operator:main", + "serve=ray.serve.scripts:cli", ] }, include_package_data=True,