2
0
mirror of https://github.com/frappe/bench.git synced 2025-02-02 19:08:24 +00:00

merge: merged develop into dependency-resolution

This commit is contained in:
Aradhya 2022-03-21 21:50:24 +05:30
commit d514f84d5f
7 changed files with 34 additions and 10 deletions

View File

@ -409,7 +409,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 install_resolved_deps( def install_resolved_deps(

View File

@ -141,9 +141,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")
@ -41,9 +41,14 @@ def reload_nginx():
@click.option("--yes", help="Yes to regeneration of supervisor config", is_flag=True, default=False) @click.option("--yes", help="Yes to regeneration of supervisor config", is_flag=True, default=False)
@click.option("--skip-redis", help="Skip redis configuration", is_flag=True, default=False) @click.option("--skip-redis", help="Skip redis configuration", is_flag=True, default=False)
def setup_supervisor(user=None, yes=False, skip_redis=False): 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 from bench.config.supervisor import update_supervisord_config, generate_supervisor_config
update_supervisord_config(user=user, yes=yes) which("supervisorctl", raise_err=True)
if "Permission denied" in get_cmd_output("supervisorctl status"):
update_supervisord_config(user=user, yes=yes)
generate_supervisor_config(bench_path=".", user=user, yes=yes, skip_redis=skip_redis) generate_supervisor_config(bench_path=".", user=user, yes=yes, skip_redis=skip_redis)

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

@ -109,7 +109,9 @@ def update_supervisord_config(user=None, yes=False):
supervisord_conf_changes += '\n' + action supervisord_conf_changes += '\n' + action
if not supervisord_conf_changes: if not supervisord_conf_changes:
logger.log("supervisord.conf not updated") logger.error("supervisord.conf not updated")
contents = "\n".join(f"{x}={y}" for x, y in updated_values.items())
print(f"Update your {supervisord_conf} with the following values:\n[{section}]\n{contents}")
return return
if not yes: if not yes:

View File

@ -163,7 +163,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_
@ -342,7 +342,13 @@ def find_benches(directory: str = None) -> List:
return return
benches = [] benches = []
for sub in os.listdir(directory):
try:
sub_directories = os.listdir(directory)
except PermissionError:
return benches
for sub in sub_directories:
sub = os.path.join(directory, sub) sub = os.path.join(directory, sub)
if os.path.isdir(sub) and not os.path.islink(sub): if os.path.isdir(sub) and not os.path.islink(sub):
if is_bench_directory(sub): if is_bench_directory(sub):

View File

@ -253,7 +253,15 @@ def restart_supervisor_processes(bench_path=".", web_workers=False):
bench.run(cmd) bench.run(cmd)
else: 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:
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: if web_workers and f"{bench_name}-web:" in supervisor_status:
group = f"{bench_name}-web:\t" group = f"{bench_name}-web:\t"
@ -269,7 +277,7 @@ def restart_supervisor_processes(bench_path=".", web_workers=False):
else: else:
group = "frappe:" group = "frappe:"
bench.run(f"supervisorctl restart {group}") bench.run(f"{sudo}supervisorctl restart {group}")
def restart_systemd_processes(bench_path=".", web_workers=False): def restart_systemd_processes(bench_path=".", web_workers=False):