Files
computer-playbook/cli/deploy/development/restart.py
T
kevinveenbirkenbach 4e0d09e773 refactor(dev-orchestrator): centralize image build and add up --when-down SPOT
- Introduce cli.deploy.development build subcommand as single build SPOT
- Remove legacy compose.build_infinito implementation
- Make up use build-missing logic via build handler
- Add --when-down flag to up (skip startup if stack already running)
- Simplify restart/run to reuse up handler
- Ensure tests use up --when-down to avoid stack interference
- Make test targets depend on build-missing

https://chatgpt.com/share/696fd3c9-99f0-800f-a0ab-33a91058419a
2026-01-20 20:13:02 +01:00

47 lines
1.2 KiB
Python

from __future__ import annotations
import argparse
import os
from .stop import handler as stop_handler
from .up import handler as up_handler
def add_parser(sub: argparse._SubParsersAction) -> None:
p = sub.add_parser(
"restart",
help="Restart the compose stack: stop -> up (no force by default).",
)
p.add_argument(
"--distro",
default=os.environ.get("INFINITO_DISTRO", "arch"),
choices=["arch", "debian", "ubuntu", "fedora", "centos"],
help="Target distro (compose env INFINITO_DISTRO).",
)
p.add_argument(
"--skip-entry-init",
action="store_true",
help="Do not run entry.sh init after stack is up.",
)
p.set_defaults(_handler=handler)
def handler(args: argparse.Namespace) -> int:
# 1) stop (best-effort)
class _StopArgs:
distro = args.distro
stop_rc = stop_handler(_StopArgs())
if stop_rc != 0:
# Keep going anyway; up might still succeed
print(f">>> WARNING: stop returned rc={stop_rc}, continuing with up")
# 2) up (normal behavior, no force unless flags provided)
class _UpArgs:
distro = args.distro
skip_entry_init = bool(args.skip_entry_init)
return int(up_handler(_UpArgs()))