mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 08:30:39 +00:00
add set-mariadb-host
This commit is contained in:
parent
585d041b19
commit
9cc3c4492b
10
bench/cli.py
10
bench/cli.py
@ -8,10 +8,11 @@ from .utils import setup_sudoers as _setup_sudoers
|
||||
from .utils import start as _start
|
||||
from .utils import setup_procfile as _setup_procfile
|
||||
from .utils import set_nginx_port as _set_nginx_port
|
||||
from .utils import set_nginx_port as _set_nginx_port
|
||||
from .utils import set_default_site as _set_default_site
|
||||
from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_frappe, setup_logging,
|
||||
get_config, update_config, restart_supervisor_processes, put_config, default_config, update_requirements,
|
||||
backup_all_sites, backup_site, get_sites, prime_wheel_cache, is_root)
|
||||
backup_all_sites, backup_site, get_sites, prime_wheel_cache, is_root, set_mariadb_host)
|
||||
from .app import get_app as _get_app
|
||||
from .app import new_app as _new_app
|
||||
from .app import pull_all_apps
|
||||
@ -196,6 +197,12 @@ def set_nginx_port(site, port):
|
||||
"Set nginx port for site"
|
||||
_set_nginx_port(site, port)
|
||||
|
||||
@click.command('set-mariadb-host')
|
||||
@click.argument('host')
|
||||
def _set_mariadb_host(host):
|
||||
"Set MariaDB host for bench"
|
||||
set_mariadb_host(host)
|
||||
|
||||
@click.command('set-default-site')
|
||||
@click.argument('site')
|
||||
def set_default_site(site):
|
||||
@ -384,6 +391,7 @@ bench.add_command(restart)
|
||||
bench.add_command(config)
|
||||
bench.add_command(start)
|
||||
bench.add_command(set_nginx_port)
|
||||
bench.add_command(_set_mariadb_host)
|
||||
bench.add_command(set_default_site)
|
||||
bench.add_command(migrate_3to4)
|
||||
bench.add_command(shell)
|
||||
|
@ -279,3 +279,17 @@ def is_root():
|
||||
if os.getuid() == 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_mariadb_host(host, bench='.'):
|
||||
update_common_site_config({'db_host': host}, bench=bench)
|
||||
|
||||
def update_common_site_config(ddict, bench='.'):
|
||||
update_json_file(os.path.join(bench, 'sites', 'common_site_config.json'), ddict)
|
||||
|
||||
def update_json_file(filename, ddict):
|
||||
with open(filename, 'r') as f:
|
||||
content = json.load(f)
|
||||
content.update(ddict)
|
||||
with open(filename, 'w') as f:
|
||||
content = json.dump(content, f, indent=1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user