feat(host): emit steps during start, stop, and delete operations

This commit is contained in:
mwiegand 2026-05-06 20:07:00 +02:00
parent d977098344
commit 38d04e8551
No known key found for this signature in database

View file

@ -84,6 +84,7 @@ def start_instance(
env = _load_instance_env(instance_dir / "instance.env") env = _load_instance_env(instance_dir / "instance.env")
_emit_step("mounting runtime overlay...", on_stdout, passthrough)
run_command( run_command(
[ [
"fuse-overlayfs", "fuse-overlayfs",
@ -101,10 +102,12 @@ def start_instance(
should_cancel=should_cancel, should_cancel=should_cancel,
) )
_emit_step("copying server.cfg to runtime...", on_stdout, passthrough)
target_cfg = runtime_dir / "merged" / "left4dead2" / "cfg" / "server.cfg" target_cfg = runtime_dir / "merged" / "left4dead2" / "cfg" / "server.cfg"
target_cfg.parent.mkdir(parents=True, exist_ok=True) target_cfg.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(instance_dir / "server.cfg", target_cfg) shutil.copy2(instance_dir / "server.cfg", target_cfg)
_emit_step("starting systemd service...", on_stdout, passthrough)
start_service( start_service(
name, name,
on_stdout=on_stdout, on_stdout=on_stdout,
@ -112,6 +115,7 @@ def start_instance(
passthrough=passthrough, passthrough=passthrough,
should_cancel=should_cancel, should_cancel=should_cancel,
) )
_emit_step("start complete.", on_stdout, passthrough)
def stop_instance( def stop_instance(
@ -124,6 +128,7 @@ def stop_instance(
should_cancel: Callable[[], bool] | None = None, should_cancel: Callable[[], bool] | None = None,
) -> None: ) -> None:
root = get_left4me_root() if root is None else Path(root) root = get_left4me_root() if root is None else Path(root)
_emit_step("stopping systemd service...", on_stdout, passthrough)
stop_service( stop_service(
name, name,
on_stdout=on_stdout, on_stdout=on_stdout,
@ -131,6 +136,7 @@ def stop_instance(
passthrough=passthrough, passthrough=passthrough,
should_cancel=should_cancel, should_cancel=should_cancel,
) )
_emit_step("unmounting runtime overlay...", on_stdout, passthrough)
run_command( run_command(
["fusermount3", "-u", str(root / "runtime" / name / "merged")], ["fusermount3", "-u", str(root / "runtime" / name / "merged")],
on_stdout=on_stdout, on_stdout=on_stdout,
@ -138,6 +144,7 @@ def stop_instance(
passthrough=passthrough, passthrough=passthrough,
should_cancel=should_cancel, should_cancel=should_cancel,
) )
_emit_step("stop complete.", on_stdout, passthrough)
def delete_instance( def delete_instance(
@ -156,6 +163,7 @@ def delete_instance(
if not instance_dir.exists() and not runtime_dir.exists(): if not instance_dir.exists() and not runtime_dir.exists():
return return
_emit_step("stopping systemd service (if running)...", on_stdout, passthrough)
stop_service( stop_service(
name, name,
on_stdout=on_stdout, on_stdout=on_stdout,
@ -166,6 +174,7 @@ def delete_instance(
merged = runtime_dir / "merged" merged = runtime_dir / "merged"
if merged.is_mount(): if merged.is_mount():
_emit_step("unmounting runtime overlay (if mounted)...", on_stdout, passthrough)
run_command( run_command(
["fusermount3", "-u", str(merged)], ["fusermount3", "-u", str(merged)],
on_stdout=on_stdout, on_stdout=on_stdout,
@ -174,7 +183,9 @@ def delete_instance(
should_cancel=should_cancel, should_cancel=should_cancel,
) )
_emit_step("removing instance files...", on_stdout, passthrough)
if instance_dir.exists(): if instance_dir.exists():
shutil.rmtree(instance_dir) shutil.rmtree(instance_dir)
if runtime_dir.exists(): if runtime_dir.exists():
shutil.rmtree(runtime_dir) shutil.rmtree(runtime_dir)
_emit_step("delete complete.", on_stdout, passthrough)