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)

This commit is contained in:
plumbeo 2016-07-28 20:49:43 +02:00 committed by Maxime Beauchemin
parent 29e3dd404d
commit 88726773f1
2 changed files with 6 additions and 2 deletions

View File

@ -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())

View File

@ -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