wait for instance to fully terminate before restart

This commit is contained in:
2026-05-23 20:31:48 +02:00
parent ad57764636
commit d0cda51639
3 changed files with 7 additions and 1 deletions
+7 -1
View File
@@ -1,4 +1,5 @@
import subprocess
import time
import typer
args = ["qs", "-c", "zshell"]
@@ -8,7 +9,7 @@ app = typer.Typer()
@app.command()
def kill():
subprocess.run(args + ["kill"], check=True)
subprocess.run(args + ["kill"], check=False)
@app.command()
@@ -19,6 +20,11 @@ def start(no_daemon: bool = False):
@app.command()
def restart(no_daemon: bool = False):
subprocess.run(args + ["kill"], check=False)
for _ in range(50):
result = subprocess.run(args + ["kill"], capture_output=True)
if result.returncode == 255:
break
time.sleep(0.05)
subprocess.run(args + ["-n"] + ([] if no_daemon else ["-d"]), check=True)