From fc7c047c280c443fa85f33f90e572412f206dbff Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 17 Mar 2022 15:04:22 +0530 Subject: [PATCH] fix: Allow sudo restart for supervisor (backwards compatibility) --- bench/utils/bench.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bench/utils/bench.py b/bench/utils/bench.py index 9f170ba1..28ca31f3 100644 --- a/bench/utils/bench.py +++ b/bench/utils/bench.py @@ -253,7 +253,13 @@ def restart_supervisor_processes(bench_path=".", web_workers=False): bench.run(cmd) else: - supervisor_status = get_cmd_output("supervisorctl status", cwd=bench_path) + sudo = "" + try: + supervisor_status = get_cmd_output("supervisorctl status", cwd=bench_path) + except Exception as e: + if e.returncode == 127: + sudo = "sudo " + supervisor_status = get_cmd_output("sudo supervisorctl status", cwd=bench_path) if web_workers and f"{bench_name}-web:" in supervisor_status: group = f"{bench_name}-web:\t" @@ -269,7 +275,7 @@ def restart_supervisor_processes(bench_path=".", web_workers=False): else: group = "frappe:" - bench.run(f"supervisorctl restart {group}") + bench.run(f"{sudo}supervisorctl restart {group}") def restart_systemd_processes(bench_path=".", web_workers=False):