fix(gateway): serialize shared runtime lifecycle
This commit is contained in:
1 parent
7384fbfffc
commit
eafc0bc6eb
6 files changed
+263
-52
No files matched your search
+1
-10
@@ -14,7 +14,6 @@ from rich.console import Console
|
||||
|
||||
from nanobot.config.schema import Config
|
||||
from nanobot.gateway import (
|
||||
GatewayClientLease,
|
||||
GatewayRuntime,
|
||||
GatewayRuntimePaths,
|
||||
GatewayStartOptions,
|
||||
@@ -209,18 +208,12 @@ def create_gateway_app(
|
||||
)
|
||||
print_status(result.status)
|
||||
raise typer.Exit(1)
|
||||
promoted = False
|
||||
if result.ok or result.message == "gateway_already_running":
|
||||
promoted = GatewayClientLease(
|
||||
runtime,
|
||||
kind="gateway-background",
|
||||
).mark_persistent()
|
||||
if result.ok:
|
||||
console.print("[green]Gateway started in the background.[/green]")
|
||||
print_status(runtime.status())
|
||||
return
|
||||
if result.message == "gateway_already_running":
|
||||
if promoted:
|
||||
if result.promoted:
|
||||
console.print(
|
||||
"[green]Existing on-demand gateway promoted to persistent "
|
||||
"background mode.[/green]"
|
||||
@@ -290,8 +283,6 @@ def create_gateway_app(
|
||||
"""Stop the background gateway."""
|
||||
runtime = runtime_for_instance(workspace=workspace, config=config)
|
||||
result = runtime.stop(timeout_s=timeout)
|
||||
if result.ok or result.message == "gateway_not_running":
|
||||
GatewayClientLease(runtime, kind="gateway-stop").clear()
|
||||
if result.ok:
|
||||
console.print("[green]Gateway stopped.[/green]")
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user