mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
fix: update supervisord.conf while generating supervisor.conf
This commit is contained in:
parent
d2a70badd3
commit
1f0a5ce556
@ -1,17 +1,26 @@
|
||||
import os, getpass, click
|
||||
# imports - standard imports
|
||||
import configparser
|
||||
import getpass
|
||||
import os
|
||||
|
||||
# imports - module imports
|
||||
import bench
|
||||
from bench.app import get_current_frappe_version, use_rq
|
||||
from bench.utils import get_bench_name, find_executable
|
||||
from bench.config.common_site_config import get_config, update_config, get_gunicorn_workers
|
||||
|
||||
# imports - third party imports
|
||||
import click
|
||||
|
||||
|
||||
def generate_supervisor_config(bench_path, user=None, yes=False):
|
||||
from bench.app import get_current_frappe_version, use_rq
|
||||
from bench.utils import get_bench_name, find_executable
|
||||
from bench.config.common_site_config import get_config, update_config, get_gunicorn_workers
|
||||
|
||||
template = bench.env.get_template('supervisor.conf')
|
||||
if not user:
|
||||
user = getpass.getuser()
|
||||
|
||||
config = get_config(bench_path=bench_path)
|
||||
update_supervisord_conf(user=user)
|
||||
|
||||
template = bench.env.get_template('supervisor.conf')
|
||||
config = get_config(bench_path=bench_path)
|
||||
bench_dir = os.path.abspath(bench_path)
|
||||
|
||||
config = template.render(**{
|
||||
@ -44,3 +53,24 @@ def generate_supervisor_config(bench_path, user=None, yes=False):
|
||||
update_config({'restart_supervisor_on_update': True}, bench_path=bench_path)
|
||||
update_config({'restart_systemd_on_update': False}, bench_path=bench_path)
|
||||
|
||||
|
||||
def get_supervisord_conf():
|
||||
possibilities = ("supervisord.conf", "etc/supervisord.conf", "/etc/supervisord.conf", "/etc/supervisor/supervisord.conf", "/etc/supervisord.conf")
|
||||
|
||||
for possibility in possibilities:
|
||||
if os.path.exists(possibility):
|
||||
return possibility
|
||||
|
||||
|
||||
def update_supervisord_conf(user):
|
||||
"""From bench v5.0, we're moving to supervisor running as user"""
|
||||
supervisord_conf = get_supervisord_conf() or "supervisord.conf"
|
||||
section = "unix_http_server"
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(supervisord_conf)
|
||||
config[section]["chmod"] = "0760"
|
||||
config[section]["chown"] = user
|
||||
|
||||
with open(supervisord_conf, "w") as f:
|
||||
config.write(f)
|
||||
|
Loading…
Reference in New Issue
Block a user