naas_abi_cli.cli.stack
What it is
Click-based CLI commands for managing and inspecting a local “ABI stack” running under Docker Compose:
- Start/stop the stack
- Follow logs (optionally per-service)
- Show a Rich table status view
- Launch a terminal UI (TUI)
Public API
Click command groups/commands
stack()(Click group:stack)- Top-level group for stack-related subcommands.
stack_start()- Starts the stack (runs
docker compose up -dviarun_compose), retries on failure, checks for container errors, opens the service portal URL on success.
- Starts the stack (runs
stack_stop(volumes: bool)- Stops the stack (
docker compose down), with optional volume removal (-v).
- Stops the stack (
stack_logs(service: str | None)- Follows Docker Compose logs. If
serviceis provided, follows that service’s logs.
- Follows Docker Compose logs. If
stack_status()- Prints a Rich table with service state, health, readiness, and readiness probe/source.
stack_tui(interval: float)- Runs an interactive TUI (
StackTUI) refreshing everyintervalseconds.
- Runs an interactive TUI (
Top-level commands (non-grouped)
These duplicate the grouped functionality under different command names:
start()→ same behavior asstack_start()stop(volumes: bool)→ same behavior asstack_stop()logs(service: str | None)→ same behavior asstack_logs()
Configuration/Dependencies
- Browser opening
- Opens
SERVICE_PORTAL_URL = "http://127.0.0.1:8080/"viawebbrowser.open()after a successful start.
- Opens
- Runtime/stack integrations
- Uses
run_compose,compose_service_list,compose_service_states,compose_service_logs,compose_logs_followfromnaas_abi_cli.cli.stack_runtime. - Uses
SERVICE_CATALOG,evaluate_service_readinessfromnaas_abi_cli.cli.stack_services. - Uses
StackTUIfromnaas_abi_cli.cli.stack_tui.
- Uses
- Third-party libraries
clickfor CLIrichfor the status table output
Usage
Minimal Python usage (invoking command functions directly):
from naas_abi_cli.cli.stack import stack_status, stack_start, stack_stop
stack_start()
stack_status()
stack_stop(volumes=False)
Typical CLI usage (as provided by Click entrypoints in your app) will expose commands similar to:
stack startstack stop [-v|--volumes]stack logs [service]stack statusstack tui [--interval SECONDS]
Caveats
- Startup retries:
docker compose up -dis retried up to 2 times on failure.- After a successful
up, services are checked for error conditions; if any are in error,up -dis retried up to the same limit.
- Error detection rules:
- A service is considered “in error” if:
- health is
"unhealthy", or - state is
"dead"or"removing", or - state is
"exited"with a non-zero exit code, - except: “one-shot” services (from
SERVICE_CATALOG) exiting with code0are not treated as errors.
- health is
- A service is considered “in error” if:
- On final failure due to service errors, recent logs are printed (tail=160 lines) for each erroring service.