2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-28 06:49:06 +00:00

fix: Allow sudo restart for supervisor (backwards compatibility)

This commit is contained in:
Gavin D'souza 2022-03-17 15:04:22 +05:30
parent 7a4ade9192
commit fc7c047c28

View File

@ -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):