feat: integrate API lifecycle with teardown and update dependencies
This commit is contained in:
@@ -131,6 +131,27 @@ def deploy(config: DecnetConfig, dry_run: bool = False, no_cache: bool = False)
|
||||
_print_status(config)
|
||||
|
||||
|
||||
def _kill_api() -> None:
|
||||
"""Find and kill any running DECNET API (uvicorn) processes."""
|
||||
import psutil
|
||||
import signal
|
||||
import os
|
||||
|
||||
_killed: bool = False
|
||||
for _proc in psutil.process_iter(['pid', 'name', 'cmdline']):
|
||||
try:
|
||||
_cmd = _proc.info['cmdline']
|
||||
if _cmd and "uvicorn" in _cmd and "decnet.web.api:app" in _cmd:
|
||||
console.print(f"[yellow]Stopping DECNET API (PID {_proc.info['pid']})...[/]")
|
||||
os.kill(_proc.info['pid'], signal.SIGTERM)
|
||||
_killed = True
|
||||
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||
continue
|
||||
|
||||
if _killed:
|
||||
console.print("[green]API stopped.[/]")
|
||||
|
||||
|
||||
def teardown(decky_id: str | None = None) -> None:
|
||||
state = load_state()
|
||||
if state is None:
|
||||
@@ -159,6 +180,10 @@ def teardown(decky_id: str | None = None) -> None:
|
||||
teardown_host_macvlan(decky_range)
|
||||
remove_macvlan_network(client)
|
||||
clear_state()
|
||||
|
||||
# Kill API when doing full teardown
|
||||
_kill_api()
|
||||
|
||||
net_driver = "IPvlan" if config.ipvlan else "MACVLAN"
|
||||
console.print(f"[green]All deckies torn down. {net_driver} network removed.[/]")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user