2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-09 00:21:23 +00:00

commands to set redis hosts

This commit is contained in:
Shridhar Patil 2019-11-03 10:59:56 +05:30
parent 1c8115df16
commit 787625fe28
3 changed files with 46 additions and 1 deletions

View File

@ -47,7 +47,7 @@ bench_command.add_command(switch_to_develop)
from bench.commands.utils import (start, restart, set_nginx_port, set_ssl_certificate, set_ssl_certificate_key, set_url_root,
set_mariadb_host, set_default_site, download_translations, shell, backup_site, backup_all_sites, release, renew_lets_encrypt,
disable_production, bench_src, prepare_beta_release)
disable_production, bench_src, prepare_beta_release, set_redis_cache_host, set_redis_queue_host, set_redis_socketio_host)
bench_command.add_command(start)
bench_command.add_command(restart)
bench_command.add_command(set_nginx_port)
@ -55,6 +55,9 @@ bench_command.add_command(set_ssl_certificate)
bench_command.add_command(set_ssl_certificate_key)
bench_command.add_command(set_url_root)
bench_command.add_command(set_mariadb_host)
bench_command.add_command(set_redis_cache_host)
bench_command.add_command(set_redis_queue_host)
bench_command.add_command(set_redis_socketio_host)
bench_command.add_command(set_default_site)
bench_command.add_command(download_translations)
bench_command.add_command(shell)

View File

@ -67,6 +67,39 @@ def set_mariadb_host(host):
from bench.utils import set_mariadb_host
set_mariadb_host(host)
@click.command('set-redis-cache-host')
@click.argument('host')
def set_redis_cache_host(host):
"""
Set Redis cache host for bench
Eg: bench set-redis-cache-host localhost:6379/1
"""
from bench.utils import set_redis_cache_host
set_redis_cache_host(host)
@click.command('set-redis-queue-host')
@click.argument('host')
def set_redis_queue_host(host):
"""
Set Redis queue host for bench
Eg: bench set-redis-queue-host localhost:6379/2
"""
from bench.utils import set_redis_queue_host
set_redis_queue_host(host)
@click.command('set-redis-socketio-host')
@click.argument('host')
def set_redis_socketio_host(host):
"""
Set Redis socketio host for bench
Eg: bench set-redis-socketio-host localhost:6379/3
"""
from bench.utils import set_redis_socketio_host
set_redis_socketio_host(host)
@click.command('set-default-site')
@click.argument('site')

View File

@ -524,6 +524,15 @@ def is_root():
def set_mariadb_host(host, bench_path='.'):
update_common_site_config({'db_host': host}, bench_path=bench_path)
def set_redis_cache_host(host, bench_path='.'):
update_common_site_config({'redis_cache': "redis://{}".format(host)}, bench_path=bench_path)
def set_redis_queue_host(host, bench_path='.'):
update_common_site_config({'redis_queue': "redis://{}".format(host)}, bench_path=bench_path)
def set_redis_socketio_host(host, bench_path='.'):
update_common_site_config({'redis_socketio': "redis://{}".format(host)}, bench_path=bench_path)
def update_common_site_config(ddict, bench_path='.'):
update_json_file(os.path.join(bench_path, 'sites', 'common_site_config.json'), ddict)