diff --git a/bench/app.py b/bench/app.py index 5ce0f8fc..f8c1ba22 100755 --- a/bench/app.py +++ b/bench/app.py @@ -320,6 +320,7 @@ def get_app( repo_name = app.repo branch = app.tag bench_setup = False + restart_bench = not init_bench if not is_bench_directory(bench_path): if not init_bench: @@ -343,7 +344,6 @@ def get_app( "color": None, }) - cloned_path = os.path.join(bench_path, "apps", repo_name) dir_already_exists = os.path.isdir(cloned_path) to_clone = not dir_already_exists @@ -368,7 +368,7 @@ def get_app( or overwrite or click.confirm("Do you want to reinstall the existing application?") ): - app.install(verbose=verbose, skip_assets=skip_assets) + app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench) def new_app(app, no_git=None, bench_path="."): diff --git a/bench/bench.py b/bench/bench.py index 655693e2..f359be7c 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -138,9 +138,9 @@ class Bench(Base, Validator): if conf.get("developer_mode"): restart_process_manager(bench_path=self.name, web_workers=web) - if supervisor or conf.get("restart_supervisor_on_update"): + if supervisor and conf.get("restart_supervisor_on_update"): restart_supervisor_processes(bench_path=self.name, web_workers=web) - if systemd or conf.get("restart_systemd_on_update"): + if systemd and conf.get("restart_systemd_on_update"): restart_systemd_processes(bench_path=self.name, web_workers=web) def get_installed_apps(self) -> List: diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 99b06606..42672aa1 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -6,7 +6,7 @@ import sys import click # imports - module imports -from bench.utils import exec_cmd, run_playbook +from bench.utils import exec_cmd, run_playbook, which @click.group(help="Setup command group for enabling setting up a Frappe environment") @@ -44,6 +44,8 @@ def setup_supervisor(user=None, yes=False, skip_redis=False): from bench.utils import get_cmd_output from bench.config.supervisor import update_supervisord_config, generate_supervisor_config + which("supervisorctl", raise_err=True) + if "Permission denied" in get_cmd_output("supervisorctl status"): update_supervisord_config(user=user, yes=yes) diff --git a/bench/commands/utils.py b/bench/commands/utils.py index 20b5a796..b2d8a301 100644 --- a/bench/commands/utils.py +++ b/bench/commands/utils.py @@ -23,6 +23,9 @@ def start(no_dev, concurrency, procfile, no_prefix, man): @click.option('--systemd', is_flag=True, default=False) def restart(web, supervisor, systemd): from bench.bench import Bench + if not systemd and not web: + supervisor = True + Bench(".").reload(web, supervisor, systemd) diff --git a/bench/utils/__init__.py b/bench/utils/__init__.py index f75fe263..dde12acc 100644 --- a/bench/utils/__init__.py +++ b/bench/utils/__init__.py @@ -133,7 +133,7 @@ def which(executable: str, raise_err: bool = False) -> str: exec_ = which(executable) if not exec_ and raise_err: - raise ValueError(f"{executable} not found.") + raise FileNotFoundError(f"{executable} not found in PATH") return exec_ diff --git a/bench/utils/bench.py b/bench/utils/bench.py index 28ca31f3..e0be48b9 100644 --- a/bench/utils/bench.py +++ b/bench/utils/bench.py @@ -258,8 +258,10 @@ def restart_supervisor_processes(bench_path=".", web_workers=False): 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) + log("restart failed: Couldn't find supervisorctl in PATH", level=3) + return + 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"