2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-10 17:24:41 +00:00

fix(restart): Setup restarts vars with fallback

This commit is contained in:
Gavin D'souza 2022-03-21 13:37:16 +05:30
parent fc7c047c28
commit af14bafe21
6 changed files with 15 additions and 8 deletions

View File

@ -320,6 +320,7 @@ def get_app(
repo_name = app.repo repo_name = app.repo
branch = app.tag branch = app.tag
bench_setup = False bench_setup = False
restart_bench = not init_bench
if not is_bench_directory(bench_path): if not is_bench_directory(bench_path):
if not init_bench: if not init_bench:
@ -343,7 +344,6 @@ def get_app(
"color": None, "color": None,
}) })
cloned_path = os.path.join(bench_path, "apps", repo_name) cloned_path = os.path.join(bench_path, "apps", repo_name)
dir_already_exists = os.path.isdir(cloned_path) dir_already_exists = os.path.isdir(cloned_path)
to_clone = not dir_already_exists to_clone = not dir_already_exists
@ -368,7 +368,7 @@ def get_app(
or overwrite or overwrite
or click.confirm("Do you want to reinstall the existing application?") 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="."): def new_app(app, no_git=None, bench_path="."):

View File

@ -138,9 +138,9 @@ class Bench(Base, Validator):
if conf.get("developer_mode"): if conf.get("developer_mode"):
restart_process_manager(bench_path=self.name, web_workers=web) 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) 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) restart_systemd_processes(bench_path=self.name, web_workers=web)
def get_installed_apps(self) -> List: def get_installed_apps(self) -> List:

View File

@ -6,7 +6,7 @@ import sys
import click import click
# imports - module imports # 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") @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.utils import get_cmd_output
from bench.config.supervisor import update_supervisord_config, generate_supervisor_config 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"): if "Permission denied" in get_cmd_output("supervisorctl status"):
update_supervisord_config(user=user, yes=yes) update_supervisord_config(user=user, yes=yes)

View File

@ -23,6 +23,9 @@ def start(no_dev, concurrency, procfile, no_prefix, man):
@click.option('--systemd', is_flag=True, default=False) @click.option('--systemd', is_flag=True, default=False)
def restart(web, supervisor, systemd): def restart(web, supervisor, systemd):
from bench.bench import Bench from bench.bench import Bench
if not systemd and not web:
supervisor = True
Bench(".").reload(web, supervisor, systemd) Bench(".").reload(web, supervisor, systemd)

View File

@ -133,7 +133,7 @@ def which(executable: str, raise_err: bool = False) -> str:
exec_ = which(executable) exec_ = which(executable)
if not exec_ and raise_err: if not exec_ and raise_err:
raise ValueError(f"{executable} not found.") raise FileNotFoundError(f"{executable} not found in PATH")
return exec_ return exec_

View File

@ -258,6 +258,8 @@ def restart_supervisor_processes(bench_path=".", web_workers=False):
supervisor_status = get_cmd_output("supervisorctl status", cwd=bench_path) supervisor_status = get_cmd_output("supervisorctl status", cwd=bench_path)
except Exception as e: except Exception as e:
if e.returncode == 127: if e.returncode == 127:
log("restart failed: Couldn't find supervisorctl in PATH", level=3)
return
sudo = "sudo " sudo = "sudo "
supervisor_status = get_cmd_output("sudo supervisorctl status", cwd=bench_path) supervisor_status = get_cmd_output("sudo supervisorctl status", cwd=bench_path)