Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions projects/fal/src/fal/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,16 @@ def list(self, *, since=None) -> List[RunnerInfo]:
"""
return runners_api.list_runners(self.client, since=since)

def stop(self, runner_id: str) -> None:
def stop(self, runner_id: str, replace_first: bool = False) -> None:
"""Gracefully stop a runner.

Args:
runner_id: The ID of the runner to stop.
replace_first: Whether to replace the runner before stopping it.
"""
return runners_api.stop_runner(self.client, runner_id)
return runners_api.stop_runner(
self.client, runner_id, replace_first=replace_first
)

def kill(self, runner_id: str) -> None:
"""Forcefully kill a runner.
Expand Down
6 changes: 4 additions & 2 deletions projects/fal/src/fal/api/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ def list_runners(
return conn.list_runners(start_time=since)


def stop_runner(client: SyncServerlessClient, runner_id: str) -> None:
def stop_runner(
client: SyncServerlessClient, runner_id: str, replace_first: bool = False
) -> None:
with FalServerlessClient(client._grpc_host, client._credentials).connect() as conn:
conn.stop_runner(runner_id)
conn.stop_runner(runner_id, replace_first=replace_first)


def kill_runner(client: SyncServerlessClient, runner_id: str) -> None:
Expand Down
9 changes: 8 additions & 1 deletion projects/fal/src/fal/cli/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def stream_inputs():

def _stop(args):
client = SyncServerlessClient(host=args.host, team=args.team)
client.runners.stop(args.id)
client.runners.stop(args.id, replace_first=not args.no_replace)


def _kill(args):
Expand Down Expand Up @@ -356,6 +356,13 @@ def _add_stop_parser(subparsers, parents):
"id",
help="Runner ID.",
)
parser.add_argument(
"-r",
"--replace",
action="store_true",
default=False,
help="Stop the runner after first spawning a replacement.",
)
parser.set_defaults(func=_stop)


Expand Down
6 changes: 4 additions & 2 deletions projects/fal/src/fal/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,8 +1123,10 @@ def list_secrets(
for secret in response.secrets
]

def stop_runner(self, runner_id: str) -> None:
request = isolate_proto.StopRunnerRequest(runner_id=runner_id)
def stop_runner(self, runner_id: str, replace_first: bool = False) -> None:
request = isolate_proto.StopRunnerRequest(
runner_id=runner_id, replace_first=replace_first
)
self.stub.StopRunner(request)

def kill_runner(self, runner_id: str) -> None:
Expand Down
Loading