mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
[Minor] Added disable-production command to the bench
This commit is contained in:
parent
15492630af
commit
02922107f4
@ -45,8 +45,9 @@ bench_command.add_command(backup_all_sites)
|
||||
bench_command.add_command(release)
|
||||
bench_command.add_command(renew_lets_encrypt)
|
||||
|
||||
from bench.commands.setup import setup
|
||||
from bench.commands.setup import setup, disable_production
|
||||
bench_command.add_command(setup)
|
||||
bench_command.add_command(disable_production)
|
||||
|
||||
from bench.commands.config import config
|
||||
bench_command.add_command(config)
|
||||
|
@ -93,6 +93,11 @@ def setup_config():
|
||||
from bench.config.common_site_config import make_config
|
||||
make_config('.')
|
||||
|
||||
@click.command('disable-production')
|
||||
def disable_production():
|
||||
"""Disable production environment for the bench"""
|
||||
from bench.config.production_setup import disbable_production
|
||||
disable_production('.')
|
||||
|
||||
setup.add_command(setup_sudoers)
|
||||
setup.add_command(setup_nginx)
|
||||
|
@ -29,6 +29,30 @@ def setup_production(user, bench_path='.'):
|
||||
|
||||
service('nginx', 'restart')
|
||||
|
||||
def disable_production(bench_path='.'):
|
||||
bench_name = get_bench_name(bench_path)
|
||||
|
||||
# supervisorctl
|
||||
supervisor_conf_extn = "ini" if is_centos7() else "conf"
|
||||
supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format(
|
||||
bench_name=bench_name, extn=supervisor_conf_extn))
|
||||
|
||||
if os.path.islink(supervisor_conf):
|
||||
os.unlink(supervisor_conf)
|
||||
|
||||
exec_cmd('supervisorctl reread')
|
||||
exec_cmd('supervisorctl reload')
|
||||
|
||||
# nginx
|
||||
nginx_conf = '/etc/nginx/conf.f/{bench_name}.conf'.format(bench_name=bench_name)
|
||||
if os.path.islink(nginx_conf):
|
||||
os.unlink(nginx_conf)
|
||||
|
||||
service('nginx', 'reload')
|
||||
if os.environ.get('NO_SERVICE_RESTART'):
|
||||
return
|
||||
|
||||
service('nginx', 'restart')
|
||||
|
||||
def service(service, option):
|
||||
if os.path.basename(get_program(['systemctl']) or '') == 'systemctl' and is_running_systemd():
|
||||
|
Loading…
Reference in New Issue
Block a user