feat(host): emit steps during start, stop, and delete operations
This commit is contained in:
parent
d977098344
commit
38d04e8551
1 changed files with 11 additions and 0 deletions
|
|
@ -84,6 +84,7 @@ def start_instance(
|
|||
|
||||
env = _load_instance_env(instance_dir / "instance.env")
|
||||
|
||||
_emit_step("mounting runtime overlay...", on_stdout, passthrough)
|
||||
run_command(
|
||||
[
|
||||
"fuse-overlayfs",
|
||||
|
|
@ -101,10 +102,12 @@ def start_instance(
|
|||
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.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(instance_dir / "server.cfg", target_cfg)
|
||||
|
||||
_emit_step("starting systemd service...", on_stdout, passthrough)
|
||||
start_service(
|
||||
name,
|
||||
on_stdout=on_stdout,
|
||||
|
|
@ -112,6 +115,7 @@ def start_instance(
|
|||
passthrough=passthrough,
|
||||
should_cancel=should_cancel,
|
||||
)
|
||||
_emit_step("start complete.", on_stdout, passthrough)
|
||||
|
||||
|
||||
def stop_instance(
|
||||
|
|
@ -124,6 +128,7 @@ def stop_instance(
|
|||
should_cancel: Callable[[], bool] | None = None,
|
||||
) -> None:
|
||||
root = get_left4me_root() if root is None else Path(root)
|
||||
_emit_step("stopping systemd service...", on_stdout, passthrough)
|
||||
stop_service(
|
||||
name,
|
||||
on_stdout=on_stdout,
|
||||
|
|
@ -131,6 +136,7 @@ def stop_instance(
|
|||
passthrough=passthrough,
|
||||
should_cancel=should_cancel,
|
||||
)
|
||||
_emit_step("unmounting runtime overlay...", on_stdout, passthrough)
|
||||
run_command(
|
||||
["fusermount3", "-u", str(root / "runtime" / name / "merged")],
|
||||
on_stdout=on_stdout,
|
||||
|
|
@ -138,6 +144,7 @@ def stop_instance(
|
|||
passthrough=passthrough,
|
||||
should_cancel=should_cancel,
|
||||
)
|
||||
_emit_step("stop complete.", on_stdout, passthrough)
|
||||
|
||||
|
||||
def delete_instance(
|
||||
|
|
@ -156,6 +163,7 @@ def delete_instance(
|
|||
if not instance_dir.exists() and not runtime_dir.exists():
|
||||
return
|
||||
|
||||
_emit_step("stopping systemd service (if running)...", on_stdout, passthrough)
|
||||
stop_service(
|
||||
name,
|
||||
on_stdout=on_stdout,
|
||||
|
|
@ -166,6 +174,7 @@ def delete_instance(
|
|||
|
||||
merged = runtime_dir / "merged"
|
||||
if merged.is_mount():
|
||||
_emit_step("unmounting runtime overlay (if mounted)...", on_stdout, passthrough)
|
||||
run_command(
|
||||
["fusermount3", "-u", str(merged)],
|
||||
on_stdout=on_stdout,
|
||||
|
|
@ -174,7 +183,9 @@ def delete_instance(
|
|||
should_cancel=should_cancel,
|
||||
)
|
||||
|
||||
_emit_step("removing instance files...", on_stdout, passthrough)
|
||||
if instance_dir.exists():
|
||||
shutil.rmtree(instance_dir)
|
||||
if runtime_dir.exists():
|
||||
shutil.rmtree(runtime_dir)
|
||||
_emit_step("delete complete.", on_stdout, passthrough)
|
||||
|
|
|
|||
Loading…
Reference in a new issue