From 88726773f125038ebc0377d683e341ed98c51727 Mon Sep 17 00:00:00 2001 From: plumbeo Date: Thu, 28 Jul 2016 20:49:43 +0200 Subject: [PATCH] Add an option to allow users to choose to what IP address the web server must bind to. Default to 0.0.0.0 (all IP addresses). (#826) --- caravel/bin/caravel | 7 +++++-- caravel/config.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/caravel/bin/caravel b/caravel/bin/caravel index 8c560f934c..3ae2b68516 100755 --- a/caravel/bin/caravel +++ b/caravel/bin/caravel @@ -24,6 +24,9 @@ manager.add_command('db', MigrateCommand) @manager.option( '-d', '--debug', action='store_true', help="Start the web server in debug mode") +@manager.option( + '-a', '--address', default=config.get("CARAVEL_WEBSERVER_ADDRESS"), + help="Specify the address to which to bind the web server") @manager.option( '-p', '--port', default=config.get("CARAVEL_WEBSERVER_PORT"), help="Specify the port on which to run the web server") @@ -33,7 +36,7 @@ manager.add_command('db', MigrateCommand) @manager.option( '-t', '--timeout', default=config.get("CARAVEL_WEBSERVER_TIMEOUT"), help="Specify the timeout (seconds) for the gunicorn web server") -def runserver(debug, port, timeout, workers): +def runserver(debug, address, port, timeout, workers): """Starts a Caravel web server""" debug = debug or config.get("DEBUG") if debug: @@ -46,7 +49,7 @@ def runserver(debug, port, timeout, workers): "gunicorn " "-w {workers} " "--timeout {timeout} " - "-b 0.0.0.0:{port} " + "-b {address}:{port} " "--limit-request-line 0 " "--limit-request-field_size 0 " "caravel:app").format(**locals()) diff --git a/caravel/config.py b/caravel/config.py index d8d12e3ad0..3780ca787a 100644 --- a/caravel/config.py +++ b/caravel/config.py @@ -23,6 +23,7 @@ BASE_DIR = os.path.abspath(os.path.dirname(__file__)) ROW_LIMIT = 50000 CARAVEL_WORKERS = 16 +CARAVEL_WEBSERVER_ADDRESS = '0.0.0.0' CARAVEL_WEBSERVER_PORT = 8088 CARAVEL_WEBSERVER_TIMEOUT = 60