diff --git a/domain-api/app/services/worker_control_service.py b/domain-api/app/services/worker_control_service.py index 03bc098..9503db3 100644 --- a/domain-api/app/services/worker_control_service.py +++ b/domain-api/app/services/worker_control_service.py @@ -36,8 +36,16 @@ def _run_shell(command: list[str], timeout: int = 20) -> subprocess.CompletedPro return subprocess.run(command, capture_output=True, text=True, timeout=timeout) -def _run_systemctl(command: list[str], timeout: int = 20, require_sudo: bool = True) -> subprocess.CompletedProcess[str]: - systemctl_command = ["systemctl", *command] +def _run_systemctl( + command: list[str], + timeout: int = 20, + require_sudo: bool = True, + no_block: bool = False, +) -> subprocess.CompletedProcess[str]: + systemctl_command = ["systemctl"] + if no_block and "--no-block" not in command: + systemctl_command.append("--no-block") + systemctl_command.extend(command) if os.geteuid() == 0 or not require_sudo: return _run_shell(systemctl_command, timeout=timeout) return _run_shell(["sudo", "-n", *systemctl_command], timeout=timeout)