diff --git a/bench/cli.py b/bench/cli.py index 20095c7b..d858c62d 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -225,6 +225,13 @@ def config_dns_multitenant(state): state = True if state == 'on' else False update_config({'dns_multitenant': state}) +@click.command('serve_default_site') +@click.argument('state', type=click.Choice(['on', 'off'])) +def config_dns_multitenant(state): + "Configure nginx to serve the default site on port 80" + state = True if state == 'on' else False + update_config({'serve_default_site': state}) + config.add_command(config_auto_update) config.add_command(config_update_bench_on_update) config.add_command(config_restart_supervisor_on_update) diff --git a/bench/config.py b/bench/config.py index 94e0150f..00a94b16 100644 --- a/bench/config.py +++ b/bench/config.py @@ -12,8 +12,6 @@ def generate_supervisor_config(bench='.'): sites_dir = os.path.join(bench_dir, "sites") sites = get_sites(bench=bench) user = getpass.getuser() - with open("sites/currentsite.txt") as f: - default_site = f.read().strip() config = template.render(**{ "bench_dir": bench_dir, @@ -40,11 +38,15 @@ def generate_nginx_config(bench='.'): sites_dir = os.path.join(bench_dir, "sites") sites = get_sites_with_config(bench=bench) user = getpass.getuser() - with open("sites/currentsite.txt") as f: - default_site = f.read().strip() - default_site = { - 'name': default_site - } + + if get_config().get('serve_default_site'): + try: + with open("sites/currentsite.txt") as f: + default_site = {'name': f.read().strip()} + except IOError: + default_site = None + else: + default_site = None config = template.render(**{ "sites_dir": sites_dir,