diff --git a/docs/img/hydrus/review-services.png b/docs/img/hydrus/review-services.png new file mode 100644 index 0000000..9f6c61f Binary files /dev/null and b/docs/img/hydrus/review-services.png differ diff --git a/scripts/run_client.py b/scripts/run_client.py index 7c29576..d2c7458 100644 --- a/scripts/run_client.py +++ b/scripts/run_client.py @@ -137,6 +137,9 @@ def parse_requirements_file(req_path: Path) -> List[str]: def verify_imports(venv_py: Path, packages: List[str]) -> bool: + # Skip mpv check as it is problematic to install and causes slow startups + packages = [p for p in packages if p.lower() != "mpv"] + # Map some package names to import names (handle common cases where package name differs from import name) import_map = { "pyyaml": "yaml", @@ -150,7 +153,6 @@ def verify_imports(venv_py: Path, packages: List[str]) -> bool: "service-identity": "service_identity", "show-in-file-manager": "showinfm", "opencv-python-headless": "cv2", - "mpv": "mpv", "pyside6": "PySide6", } @@ -1018,16 +1020,29 @@ def main(argv: Optional[List[str]] = None) -> int: print("Failed to launch client detached:", exc) return 5 else: + p = None try: - # If headless on Windows, ensure no window shows even for foreground run + # On Windows, if we are already using pythonw.exe, we don't need CREATE_NO_WINDOW + # as the process already has no console. Avoiding extra flags helps with + # service termination mapping. kwargs = {} - if os.name == "nt" and headless: + if os.name == "nt" and headless and "pythonw.exe" not in str(venv_py).lower(): kwargs["creationflags"] = 0x08000000 - subprocess.run(cmd, cwd=str(cwd), env=env, **kwargs) - return 0 - except subprocess.CalledProcessError as e: - print("hydrus client exited non-zero:", e) + + p = subprocess.Popen(cmd, cwd=str(cwd), env=env, **kwargs) + p.wait() + return p.returncode + except Exception as e: + if not args.quiet: + print(f"Hydrus client error: {e}") return 5 + finally: + # Ensure the child process is terminated if the monitor process is killed + if p and p.poll() is None: + try: + p.terminate() + except Exception: + pass if __name__ == "__main__":