diff --git a/bench/app.py b/bench/app.py index bd69152cc..322afa54a 100755 --- a/bench/app.py +++ b/bench/app.py @@ -765,9 +765,9 @@ def pull_apps(apps=None, bench_path=".", reset=False): Here are your choices: 1. Merge the {app} app manually with "git pull" / "git pull --rebase" and fix conflicts. -1. Temporarily remove your changes with "git stash" or discard them completely +2. Temporarily remove your changes with "git stash" or discard them completely with "bench update --reset" or for individual repositries "git reset --hard" -2. If your changes are helpful for others, send in a pull request via GitHub and +3. If your changes are helpful for others, send in a pull request via GitHub and wait for them to be merged in the core.""" ) sys.exit(1) diff --git a/bench/commands/install.py b/bench/commands/install.py index 31ad59b66..a0f1fd417 100644 --- a/bench/commands/install.py +++ b/bench/commands/install.py @@ -77,7 +77,7 @@ def install_nginx(user=None): setup_sudoers(user) -@click.command("virtualbox", help="Installs supervisor") +@click.command("virtualbox", help="Installs virtualbox") def install_virtualbox(): run_playbook("vm_build.yml", tag="virtualbox") diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 9b13c269a..e291f86ae 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -73,7 +73,9 @@ def setup_supervisor(user=None, yes=False, skip_redis=False, skip_supervisord=Fa generate_supervisor_config, ) - which("supervisorctl", raise_err=True) + if which("supervisorctl") is None: + click.secho("Please install `supervisor` to proceed", fg="red") + sys.exit(1) if not skip_supervisord and "Permission denied" in get_cmd_output( "supervisorctl status" diff --git a/bench/config/supervisor.py b/bench/config/supervisor.py index 1055d3baa..0eb6a8485 100644 --- a/bench/config/supervisor.py +++ b/bench/config/supervisor.py @@ -59,6 +59,7 @@ def generate_supervisor_config(bench_path, user=None, yes=False, skip_redis=Fals "skip_redis": skip_redis, "workers": config.get("workers", {}), "multi_queue_consumption": can_enable_multi_queue_consumption(bench_path), + "supervisor_startretries": 10, } ) diff --git a/bench/config/templates/nginx.conf b/bench/config/templates/nginx.conf index 5cba57828..cd6a67014 100644 --- a/bench/config/templates/nginx.conf +++ b/bench/config/templates/nginx.conf @@ -58,6 +58,7 @@ server { location /assets { try_files $uri =404; + add_header Cache-Control "max-age=31536000"; } location ~ ^/protected/(.*) { diff --git a/bench/config/templates/supervisor.conf b/bench/config/templates/supervisor.conf index 57fd85748..9303edb76 100644 --- a/bench/config/templates/supervisor.conf +++ b/bench/config/templates/supervisor.conf @@ -14,6 +14,7 @@ stopwaitsecs=40 killasgroup=true user={{ user }} directory={{ sites_dir }} +startretries={{ supervisor_startretries }} [program:{{ bench_name }}-frappe-schedule] command={{ bench_cmd }} schedule @@ -24,6 +25,7 @@ stdout_logfile={{ bench_dir }}/logs/schedule.log stderr_logfile={{ bench_dir }}/logs/schedule.error.log user={{ user }} directory={{ bench_dir }} +startretries={{ supervisor_startretries }} {% if not multi_queue_consumption %} [program:{{ bench_name }}-frappe-default-worker] @@ -39,6 +41,7 @@ directory={{ bench_dir }} killasgroup=true numprocs={{ background_workers }} process_name=%(program_name)s-%(process_num)d +startretries={{ supervisor_startretries }} {% endif %} [program:{{ bench_name }}-frappe-short-worker] @@ -54,6 +57,7 @@ directory={{ bench_dir }} killasgroup=true numprocs={{ background_workers }} process_name=%(program_name)s-%(process_num)d +startretries={{ supervisor_startretries }} [program:{{ bench_name }}-frappe-long-worker] command={{ bench_cmd }} worker --queue long{{',default,short' if multi_queue_consumption else ''}} @@ -68,6 +72,7 @@ directory={{ bench_dir }} killasgroup=true numprocs={{ background_workers }} process_name=%(program_name)s-%(process_num)d +startretries={{ supervisor_startretries }} {% for worker_name, worker_details in workers.items() %} [program:{{ bench_name }}-frappe-{{ worker_name }}-worker] @@ -83,6 +88,7 @@ directory={{ bench_dir }} killasgroup=true numprocs={{ worker_details["background_workers"] or background_workers }} process_name=%(program_name)s-%(process_num)d +startretries={{ supervisor_startretries }} {% endfor %} @@ -96,6 +102,7 @@ stdout_logfile={{ bench_dir }}/logs/redis-cache.log stderr_logfile={{ bench_dir }}/logs/redis-cache.error.log user={{ user }} directory={{ sites_dir }} +startretries={{ supervisor_startretries }} [program:{{ bench_name }}-redis-queue] command={{ redis_server }} {{ redis_queue_config }} @@ -106,6 +113,7 @@ stdout_logfile={{ bench_dir }}/logs/redis-queue.log stderr_logfile={{ bench_dir }}/logs/redis-queue.error.log user={{ user }} directory={{ sites_dir }} +startretries={{ supervisor_startretries }} {% endif %} {% if node %} @@ -118,6 +126,7 @@ stdout_logfile={{ bench_dir }}/logs/node-socketio.log stderr_logfile={{ bench_dir }}/logs/node-socketio.error.log user={{ user }} directory={{ bench_dir }} +startretries={{ supervisor_startretries }} {% endif %} [group:{{ bench_name }}-web] diff --git a/bench/utils/bench.py b/bench/utils/bench.py index 9f1daded7..c0b9a4308 100644 --- a/bench/utils/bench.py +++ b/bench/utils/bench.py @@ -313,22 +313,23 @@ def restart_supervisor_processes(bench_path=".", web_workers=False, _raise=False 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" + groups = [f"{bench_name}-web:\t"] elif f"{bench_name}-workers:" in supervisor_status: - group = f"{bench_name}-workers: {bench_name}-web:" + groups = [f"{bench_name}-web:", f"{bench_name}-workers:"] # backward compatibility elif f"{bench_name}-processes:" in supervisor_status: - group = f"{bench_name}-processes:" + groups = [f"{bench_name}-processes:"] # backward compatibility else: - group = "frappe:" + groups = ["frappe:"] - failure = bench.run(f"{sudo}supervisorctl restart {group}", _raise=_raise) - if failure: - log("restarting supervisor failed. Use `bench restart` to retry.", level=3) + for group in groups: + failure = bench.run(f"{sudo}supervisorctl restart {group}", _raise=_raise) + if failure: + log(f"restarting supervisor group `{group}` failed. Use `bench restart` to retry.", level=3) def restart_systemd_processes(bench_path=".", web_workers=False, _raise=True):