mirror of
https://github.com/frappe/bench.git
synced 2025-01-24 15:38:25 +00:00
Merge pull request #1354 from gavindsouza/skip-supervisord
fix: Suggest don't update supervisord conf
This commit is contained in:
commit
391dcf1e12
@ -49,17 +49,25 @@ def reload_nginx():
|
|||||||
@click.option(
|
@click.option(
|
||||||
"--skip-redis", help="Skip redis configuration", is_flag=True, default=False
|
"--skip-redis", help="Skip redis configuration", is_flag=True, default=False
|
||||||
)
|
)
|
||||||
def setup_supervisor(user=None, yes=False, skip_redis=False):
|
@click.option(
|
||||||
|
"--skip-supervisord",
|
||||||
|
help="Skip supervisord configuration",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
def setup_supervisor(user=None, yes=False, skip_redis=False, skip_supervisord=False):
|
||||||
from bench.utils import get_cmd_output
|
from bench.utils import get_cmd_output
|
||||||
from bench.config.supervisor import (
|
from bench.config.supervisor import (
|
||||||
update_supervisord_config,
|
check_supervisord_config,
|
||||||
generate_supervisor_config,
|
generate_supervisor_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
which("supervisorctl", raise_err=True)
|
which("supervisorctl", raise_err=True)
|
||||||
|
|
||||||
if "Permission denied" in get_cmd_output("supervisorctl status"):
|
if not skip_supervisord and "Permission denied" in get_cmd_output(
|
||||||
update_supervisord_config(user=user, yes=yes)
|
"supervisorctl status"
|
||||||
|
):
|
||||||
|
check_supervisord_config(user=user)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import bench
|
|||||||
from bench.config.nginx import make_nginx_conf
|
from bench.config.nginx import make_nginx_conf
|
||||||
from bench.config.supervisor import (
|
from bench.config.supervisor import (
|
||||||
generate_supervisor_config,
|
generate_supervisor_config,
|
||||||
update_supervisord_config,
|
check_supervisord_config,
|
||||||
)
|
)
|
||||||
from bench.config.systemd import generate_systemd_config
|
from bench.config.systemd import generate_systemd_config
|
||||||
from bench.bench import Bench
|
from bench.bench import Bench
|
||||||
@ -48,7 +48,7 @@ def setup_production(user, bench_path=".", yes=False):
|
|||||||
generate_systemd_config(bench_path=bench_path, user=user, yes=yes)
|
generate_systemd_config(bench_path=bench_path, user=user, yes=yes)
|
||||||
else:
|
else:
|
||||||
print("Setting Up supervisor...")
|
print("Setting Up supervisor...")
|
||||||
update_supervisord_config(user=user, yes=yes)
|
check_supervisord_config(user=user)
|
||||||
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
|
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
|
||||||
|
|
||||||
print("Setting Up NGINX...")
|
print("Setting Up NGINX...")
|
||||||
|
@ -79,10 +79,11 @@ def get_supervisord_conf():
|
|||||||
return possibility
|
return possibility
|
||||||
|
|
||||||
|
|
||||||
def update_supervisord_config(user=None, yes=False):
|
def check_supervisord_config(user=None):
|
||||||
"""From bench v5.x, we're moving to supervisor running as user"""
|
"""From bench v5.x, we're moving to supervisor running as user"""
|
||||||
|
# i don't think bench should be responsible for this but we're way past this now...
|
||||||
|
# removed updating supervisord conf & reload in Aug 2022 - gavin@frappe.io
|
||||||
import configparser
|
import configparser
|
||||||
from bench.config.production_setup import service
|
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
user = getpass.getuser()
|
user = getpass.getuser()
|
||||||
@ -125,20 +126,3 @@ def update_supervisord_config(user=None, yes=False):
|
|||||||
print(
|
print(
|
||||||
f"Update your {supervisord_conf} with the following values:\n[{section}]\n{contents}"
|
f"Update your {supervisord_conf} with the following values:\n[{section}]\n{contents}"
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
if not yes:
|
|
||||||
click.confirm(
|
|
||||||
f"{supervisord_conf} will be updated with the following values:\n{supervisord_conf_changes}\nDo you want to continue?",
|
|
||||||
abort=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open(supervisord_conf, "w") as f:
|
|
||||||
config.write(f)
|
|
||||||
logger.log(f"Updated supervisord.conf at '{supervisord_conf}'")
|
|
||||||
except Exception as e:
|
|
||||||
logger.log(f"Updating supervisord.conf failed due to '{e}'")
|
|
||||||
|
|
||||||
# Reread supervisor configuration, reload supervisord and supervisorctl, restart services that were started
|
|
||||||
service("supervisor", "reload")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user