mirror of
https://github.com/frappe/bench.git
synced 2025-01-23 15:08:24 +00:00
style: format everything w black
This commit is contained in:
parent
f45db01d9a
commit
c4305fd528
@ -17,6 +17,7 @@ default_config = {
|
|||||||
|
|
||||||
DEFAULT_MAX_REQUESTS = 5000
|
DEFAULT_MAX_REQUESTS = 5000
|
||||||
|
|
||||||
|
|
||||||
def setup_config(bench_path):
|
def setup_config(bench_path):
|
||||||
make_pid_folder(bench_path)
|
make_pid_folder(bench_path)
|
||||||
bench_config = get_config(bench_path)
|
bench_config = get_config(bench_path)
|
||||||
@ -62,9 +63,11 @@ def get_gunicorn_workers():
|
|||||||
|
|
||||||
return {"gunicorn_workers": multiprocessing.cpu_count() * 2 + 1}
|
return {"gunicorn_workers": multiprocessing.cpu_count() * 2 + 1}
|
||||||
|
|
||||||
|
|
||||||
def compute_max_requests_jitter(max_requests: int) -> int:
|
def compute_max_requests_jitter(max_requests: int) -> int:
|
||||||
return int(max_requests * 0.1)
|
return int(max_requests * 0.1)
|
||||||
|
|
||||||
|
|
||||||
def get_default_max_requests(worker_count: int):
|
def get_default_max_requests(worker_count: int):
|
||||||
"""Get max requests and jitter config based on number of available workers."""
|
"""Get max requests and jitter config based on number of available workers."""
|
||||||
|
|
||||||
@ -75,7 +78,6 @@ def get_default_max_requests(worker_count: int):
|
|||||||
return DEFAULT_MAX_REQUESTS
|
return DEFAULT_MAX_REQUESTS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_config_for_frappe(config, bench_path):
|
def update_config_for_frappe(config, bench_path):
|
||||||
ports = make_ports(bench_path)
|
ports = make_ports(bench_path)
|
||||||
|
|
||||||
|
@ -8,7 +8,12 @@ import bench
|
|||||||
from bench.app import use_rq
|
from bench.app import use_rq
|
||||||
from bench.utils import get_bench_name, which
|
from bench.utils import get_bench_name, which
|
||||||
from bench.bench import Bench
|
from bench.bench import Bench
|
||||||
from bench.config.common_site_config import update_config, get_gunicorn_workers, get_default_max_requests, compute_max_requests_jitter
|
from bench.config.common_site_config import (
|
||||||
|
update_config,
|
||||||
|
get_gunicorn_workers,
|
||||||
|
get_default_max_requests,
|
||||||
|
compute_max_requests_jitter,
|
||||||
|
)
|
||||||
|
|
||||||
# imports - third party imports
|
# imports - third party imports
|
||||||
import click
|
import click
|
||||||
@ -26,8 +31,12 @@ def generate_supervisor_config(bench_path, user=None, yes=False, skip_redis=Fals
|
|||||||
template = bench.config.env().get_template("supervisor.conf")
|
template = bench.config.env().get_template("supervisor.conf")
|
||||||
bench_dir = os.path.abspath(bench_path)
|
bench_dir = os.path.abspath(bench_path)
|
||||||
|
|
||||||
web_worker_count = config.get("gunicorn_workers", get_gunicorn_workers()["gunicorn_workers"])
|
web_worker_count = config.get(
|
||||||
max_requests = config.get("gunicorn_max_requests", get_default_max_requests(web_worker_count))
|
"gunicorn_workers", get_gunicorn_workers()["gunicorn_workers"]
|
||||||
|
)
|
||||||
|
max_requests = config.get(
|
||||||
|
"gunicorn_max_requests", get_default_max_requests(web_worker_count)
|
||||||
|
)
|
||||||
|
|
||||||
config = template.render(
|
config = template.render(
|
||||||
**{
|
**{
|
||||||
|
@ -9,7 +9,12 @@ import click
|
|||||||
import bench
|
import bench
|
||||||
from bench.app import use_rq
|
from bench.app import use_rq
|
||||||
from bench.bench import Bench
|
from bench.bench import Bench
|
||||||
from bench.config.common_site_config import get_gunicorn_workers, update_config, get_default_max_requests, compute_max_requests_jitter
|
from bench.config.common_site_config import (
|
||||||
|
get_gunicorn_workers,
|
||||||
|
update_config,
|
||||||
|
get_default_max_requests,
|
||||||
|
compute_max_requests_jitter,
|
||||||
|
)
|
||||||
from bench.utils import exec_cmd, which, get_bench_name
|
from bench.utils import exec_cmd, which, get_bench_name
|
||||||
|
|
||||||
|
|
||||||
@ -61,8 +66,12 @@ def generate_systemd_config(
|
|||||||
get_bench_name(bench_path) + "-frappe-long-worker@" + str(i + 1) + ".service"
|
get_bench_name(bench_path) + "-frappe-long-worker@" + str(i + 1) + ".service"
|
||||||
)
|
)
|
||||||
|
|
||||||
web_worker_count = config.get("gunicorn_workers", get_gunicorn_workers()["gunicorn_workers"])
|
web_worker_count = config.get(
|
||||||
max_requests = config.get("gunicorn_max_requests", get_default_max_requests(web_worker_count))
|
"gunicorn_workers", get_gunicorn_workers()["gunicorn_workers"]
|
||||||
|
)
|
||||||
|
max_requests = config.get(
|
||||||
|
"gunicorn_max_requests", get_default_max_requests(web_worker_count)
|
||||||
|
)
|
||||||
|
|
||||||
bench_info = {
|
bench_info = {
|
||||||
"bench_dir": bench_dir,
|
"bench_dir": bench_dir,
|
||||||
|
@ -125,7 +125,10 @@ def check_latest_version():
|
|||||||
local_version = Version(VERSION)
|
local_version = Version(VERSION)
|
||||||
|
|
||||||
if pypi_version > local_version:
|
if pypi_version > local_version:
|
||||||
log(f"A newer version of bench is available: {local_version} → {pypi_version}", stderr=True)
|
log(
|
||||||
|
f"A newer version of bench is available: {local_version} → {pypi_version}",
|
||||||
|
stderr=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def pause_exec(seconds=10):
|
def pause_exec(seconds=10):
|
||||||
|
@ -185,7 +185,9 @@ def get_required_deps(org, name, branch, deps="hooks.py"):
|
|||||||
res = requests.get(url=git_api_url, params=params).json()
|
res = requests.get(url=git_api_url, params=params).json()
|
||||||
|
|
||||||
if "message" in res:
|
if "message" in res:
|
||||||
git_url = f"https://raw.githubusercontent.com/{org}/{name}/{params['ref']}/{name}/{deps}"
|
git_url = (
|
||||||
|
f"https://raw.githubusercontent.com/{org}/{name}/{params['ref']}/{name}/{deps}"
|
||||||
|
)
|
||||||
return requests.get(git_url).text
|
return requests.get(git_url).text
|
||||||
|
|
||||||
return base64.decodebytes(res["content"].encode()).decode()
|
return base64.decodebytes(res["content"].encode()).decode()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user