mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
Merge branch 'develop' into staging
This commit is contained in:
commit
8aafc41dc7
@ -12,7 +12,10 @@ Bench is a command-line utility that helps you to install, update, and manage mu
|
|||||||
<a target="_blank" href="https://app.travis-ci.com/github/frappe/bench" title="CI Status">
|
<a target="_blank" href="https://app.travis-ci.com/github/frappe/bench" title="CI Status">
|
||||||
<img src="https://app.travis-ci.com/frappe/bench.svg?branch=develop">
|
<img src="https://app.travis-ci.com/frappe/bench.svg?branch=develop">
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank">
|
<a target="_blank" href="https://pypi.org/project/frappe-bench" title="PyPI Version">
|
||||||
|
<img src="https://badge.fury.io/py/frappe-bench.svg" alt="PyPI version">
|
||||||
|
</a>
|
||||||
|
<a target="_blank" title="Platform Compatibility">
|
||||||
<img src="https://img.shields.io/badge/platform-linux%20%7C%20osx-blue">
|
<img src="https://img.shields.io/badge/platform-linux%20%7C%20osx-blue">
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://app.fossa.com/projects/git%2Bgithub.com%2Ffrappe%2Fbench?ref=badge_shield" title="FOSSA Status">
|
<a target="_blank" href="https://app.fossa.com/projects/git%2Bgithub.com%2Ffrappe%2Fbench?ref=badge_shield" title="FOSSA Status">
|
||||||
@ -278,4 +281,4 @@ The intermediate `staging` branch exists to mediate the `bench.VERSION` conflict
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This repository has been released under the [GNU GPLv3 License](LICENSE).
|
This repository has been released under the [GNU GPLv3 License](LICENSE).
|
||||||
|
@ -26,10 +26,7 @@ from bench.utils import (
|
|||||||
)
|
)
|
||||||
from bench.utils.bench import (
|
from bench.utils.bench import (
|
||||||
build_assets,
|
build_assets,
|
||||||
get_env_cmd,
|
|
||||||
install_python_dev_dependencies,
|
install_python_dev_dependencies,
|
||||||
restart_supervisor_processes,
|
|
||||||
restart_systemd_processes,
|
|
||||||
)
|
)
|
||||||
from bench.utils.render import step
|
from bench.utils.render import step
|
||||||
|
|
||||||
@ -419,10 +416,7 @@ def install_app(
|
|||||||
build_assets(bench_path=bench_path, app=app)
|
build_assets(bench_path=bench_path, app=app)
|
||||||
|
|
||||||
if restart_bench:
|
if restart_bench:
|
||||||
if conf.get("restart_supervisor_on_update"):
|
bench.reload()
|
||||||
restart_supervisor_processes(bench_path=bench_path)
|
|
||||||
if conf.get("restart_systemd_on_update"):
|
|
||||||
restart_systemd_processes(bench_path=bench_path)
|
|
||||||
|
|
||||||
|
|
||||||
def pull_apps(apps=None, bench_path=".", reset=False):
|
def pull_apps(apps=None, bench_path=".", reset=False):
|
||||||
|
@ -131,14 +131,18 @@ class Bench(Base, Validator):
|
|||||||
run_frappe_cmd("build", bench_path=self.name)
|
run_frappe_cmd("build", bench_path=self.name)
|
||||||
|
|
||||||
@step(title="Reloading Bench Processes", success="Bench Processes Reloaded")
|
@step(title="Reloading Bench Processes", success="Bench Processes Reloaded")
|
||||||
def reload(self):
|
def reload(self, web=False, supervisor=True, systemd=True):
|
||||||
|
"""If web is True, only web workers are restarted
|
||||||
|
"""
|
||||||
conf = self.conf
|
conf = self.conf
|
||||||
if conf.get("restart_supervisor_on_update"):
|
|
||||||
restart_supervisor_processes(bench_path=self.name)
|
|
||||||
if conf.get("restart_systemd_on_update"):
|
|
||||||
restart_systemd_processes(bench_path=self.name)
|
|
||||||
if conf.get("developer_mode"):
|
if conf.get("developer_mode"):
|
||||||
restart_process_manager(bench_path=self.name)
|
restart_process_manager(bench_path=self.name, web_workers=web)
|
||||||
|
if supervisor and conf.get("restart_supervisor_on_update"):
|
||||||
|
restart_supervisor_processes(bench_path=self.name, web_workers=web)
|
||||||
|
if systemd and conf.get("restart_systemd_on_update"):
|
||||||
|
restart_systemd_processes(bench_path=self.name, web_workers=web)
|
||||||
|
|
||||||
|
|
||||||
class BenchApps(MutableSequence):
|
class BenchApps(MutableSequence):
|
||||||
def __init__(self, bench: Bench):
|
def __init__(self, bench: Bench):
|
||||||
|
12
bench/cli.py
12
bench/cli.py
@ -51,6 +51,7 @@ def cli():
|
|||||||
change_working_directory()
|
change_working_directory()
|
||||||
logger = setup_logging()
|
logger = setup_logging()
|
||||||
logger.info(command)
|
logger.info(command)
|
||||||
|
setup_clear_cache()
|
||||||
|
|
||||||
bench_config = get_config(".")
|
bench_config = get_config(".")
|
||||||
|
|
||||||
@ -216,3 +217,14 @@ def change_working_directory():
|
|||||||
|
|
||||||
if bench_path:
|
if bench_path:
|
||||||
os.chdir(bench_path)
|
os.chdir(bench_path)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_clear_cache():
|
||||||
|
from copy import copy
|
||||||
|
f = copy(os.chdir)
|
||||||
|
|
||||||
|
def _chdir(*args, **kwargs):
|
||||||
|
Bench.cache_clear()
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
os.chdir = _chdir
|
||||||
|
@ -23,14 +23,7 @@ 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
|
||||||
from bench.utils.bench import restart_supervisor_processes, restart_systemd_processes
|
Bench(".").reload(web, supervisor, systemd)
|
||||||
|
|
||||||
bench = Bench(".")
|
|
||||||
|
|
||||||
if bench.conf.get('restart_supervisor_on_update') or supervisor:
|
|
||||||
restart_supervisor_processes(bench_path='.', web_workers=web)
|
|
||||||
if bench.conf.get('restart_systemd_on_update') or systemd:
|
|
||||||
restart_systemd_processes(bench_path='.', web_workers=web)
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('set-nginx-port', help="Set NGINX port for site")
|
@click.command('set-nginx-port', help="Set NGINX port for site")
|
||||||
|
@ -9,7 +9,6 @@ patch and try again later.
|
|||||||
Corresponding changes in frappe/frappe via https://github.com/frappe/frappe/pull/15060
|
Corresponding changes in frappe/frappe via https://github.com/frappe/frappe/pull/15060
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@ -40,7 +39,7 @@ def execute(bench_path):
|
|||||||
os.makedirs(new_directory)
|
os.makedirs(new_directory)
|
||||||
|
|
||||||
for archived_site_path in old_directory.glob("*"):
|
for archived_site_path in old_directory.glob("*"):
|
||||||
shutil.move(archived_site_path, new_directory)
|
archived_site_path.rename(new_directory)
|
||||||
|
|
||||||
click.secho(f"Archived sites are now stored under {new_directory}")
|
click.secho(f"Archived sites are now stored under {new_directory}")
|
||||||
|
|
||||||
|
@ -279,12 +279,13 @@ def restart_systemd_processes(bench_path=".", web_workers=False):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def restart_process_manager(bench_path="."):
|
def restart_process_manager(bench_path=".", web_workers=False):
|
||||||
# only overmind has the restart feature, not sure other supported procmans do
|
# only overmind has the restart feature, not sure other supported procmans do
|
||||||
if which("overmind") and os.path.exists(
|
if which("overmind") and os.path.exists(
|
||||||
os.path.join(bench_path, ".overmind.sock")
|
os.path.join(bench_path, ".overmind.sock")
|
||||||
):
|
):
|
||||||
exec_cmd("overmind restart", cwd=bench_path)
|
worker = "web" if web_workers else ""
|
||||||
|
exec_cmd(f"overmind restart {worker}", cwd=bench_path)
|
||||||
|
|
||||||
|
|
||||||
def build_assets(bench_path=".", app=None):
|
def build_assets(bench_path=".", app=None):
|
||||||
@ -352,10 +353,6 @@ def update(
|
|||||||
|
|
||||||
from bench.utils import clear_command_cache
|
from bench.utils import clear_command_cache
|
||||||
from bench.utils.app import is_version_upgrade
|
from bench.utils.app import is_version_upgrade
|
||||||
from bench.utils.bench import (
|
|
||||||
restart_supervisor_processes,
|
|
||||||
restart_systemd_processes,
|
|
||||||
)
|
|
||||||
from bench.utils.system import backup_all_sites
|
from bench.utils.system import backup_all_sites
|
||||||
|
|
||||||
bench_path = os.path.abspath(".")
|
bench_path = os.path.abspath(".")
|
||||||
@ -414,11 +411,7 @@ def update(
|
|||||||
apps_dir = os.path.join(bench_path, "apps")
|
apps_dir = os.path.join(bench_path, "apps")
|
||||||
compile_dir(apps_dir, quiet=1, rx=re.compile(".*node_modules.*"))
|
compile_dir(apps_dir, quiet=1, rx=re.compile(".*node_modules.*"))
|
||||||
|
|
||||||
if restart_supervisor or conf.get("restart_supervisor_on_update"):
|
bench.reload(web=False, supervisor=restart_supervisor, systemd=restart_systemd)
|
||||||
restart_supervisor_processes(bench_path=bench_path)
|
|
||||||
|
|
||||||
if restart_systemd or conf.get("restart_systemd_on_update"):
|
|
||||||
restart_systemd_processes(bench_path=bench_path)
|
|
||||||
|
|
||||||
conf.update({"maintenance_mode": 0, "pause_scheduler": 0})
|
conf.update({"maintenance_mode": 0, "pause_scheduler": 0})
|
||||||
update_config(conf, bench_path=bench_path)
|
update_config(conf, bench_path=bench_path)
|
||||||
|
17
install.py
17
install.py
@ -251,16 +251,13 @@ def install_bench(args):
|
|||||||
if args.production:
|
if args.production:
|
||||||
extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024)
|
extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024)
|
||||||
|
|
||||||
frappe_branch = 'version-13'
|
if args.version <= 10:
|
||||||
erpnext_branch = 'version-13'
|
frappe_branch = "{0}.x.x".format(args.version)
|
||||||
|
erpnext_branch = "{0}.x.x".format(args.version)
|
||||||
|
else:
|
||||||
|
frappe_branch = "version-{0}".format(args.version)
|
||||||
|
erpnext_branch = "version-{0}".format(args.version)
|
||||||
|
|
||||||
if args.version:
|
|
||||||
if args.version <= 10:
|
|
||||||
frappe_branch = "{0}.x.x".format(args.version)
|
|
||||||
erpnext_branch = "{0}.x.x".format(args.version)
|
|
||||||
else:
|
|
||||||
frappe_branch = "version-{0}".format(args.version)
|
|
||||||
erpnext_branch = "version-{0}".format(args.version)
|
|
||||||
# Allow override of frappe_branch and erpnext_branch, regardless of args.version (which always has a default set)
|
# Allow override of frappe_branch and erpnext_branch, regardless of args.version (which always has a default set)
|
||||||
if args.frappe_branch:
|
if args.frappe_branch:
|
||||||
frappe_branch = args.frappe_branch
|
frappe_branch = args.frappe_branch
|
||||||
@ -445,7 +442,7 @@ def parse_commandline_args():
|
|||||||
parser.add_argument('--erpnext-branch', dest='erpnext_branch', action='store', help='Clone a particular branch of erpnext')
|
parser.add_argument('--erpnext-branch', dest='erpnext_branch', action='store', help='Clone a particular branch of erpnext')
|
||||||
parser.add_argument('--without-erpnext', dest='without_erpnext', action='store_true', default=False, help='Prevent fetching ERPNext')
|
parser.add_argument('--without-erpnext', dest='without_erpnext', action='store_true', default=False, help='Prevent fetching ERPNext')
|
||||||
# direct provision to install versions
|
# direct provision to install versions
|
||||||
parser.add_argument('--version', dest='version', action='store', default='12', type=int, help='Clone particular version of frappe and erpnext')
|
parser.add_argument('--version', dest='version', action='store', default=13, type=int, help='Clone particular version of frappe and erpnext')
|
||||||
# To enable testing of script using Travis, this should skip the prompt
|
# To enable testing of script using Travis, this should skip the prompt
|
||||||
parser.add_argument('--run-travis', dest='run_travis', action='store_true', default=False, help=argparse.SUPPRESS)
|
parser.add_argument('--run-travis', dest='run_travis', action='store_true', default=False, help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--without-bench-setup', dest='without_bench_setup', action='store_true', default=False, help=argparse.SUPPRESS)
|
parser.add_argument('--without-bench-setup', dest='without_bench_setup', action='store_true', default=False, help=argparse.SUPPRESS)
|
||||||
|
Loading…
Reference in New Issue
Block a user