Add UNIX socket option to runserver (#2627)

* Add UNIX socket option to runserver

Added an optional parameter to runserver to server from a UNIX socket instead of an address:port. I believe it is fairly common to server from sockets when using a web server like Nginx on the same host.

* Collapsed if/else logic for address or socket

Also wrapped help description for socket parameter
This commit is contained in:
Joe Francia 2017-04-16 23:19:02 -07:00 committed by Maxime Beauchemin
parent 6b1bf3b395
commit 70c6cad0e3
1 changed files with 9 additions and 3 deletions

View File

@ -46,8 +46,13 @@ def init():
@manager.option(
'-t', '--timeout', default=config.get("SUPERSET_WEBSERVER_TIMEOUT"),
help="Specify the timeout (seconds) for the gunicorn web server")
def runserver(debug, no_reload, address, port, timeout, workers):
"""Starts a Superset web server"""
@manager.option(
'-s', '--socket', default=config.get("SUPERSET_WEBSERVER_SOCKET"),
help="Path to a UNIX socket as an alternative to address:port, e.g. "
"/var/run/superset.sock. "
"Will override the address and port values.")
def runserver(debug, no_reload, address, port, timeout, workers, socket):
"""Starts a Superset web server."""
debug = debug or config.get("DEBUG")
if debug:
app.run(
@ -57,11 +62,12 @@ def runserver(debug, no_reload, address, port, timeout, workers):
debug=True,
use_reloader=no_reload)
else:
addr_str = " unix:{socket} " if socket else" {address}:{port} "
cmd = (
"gunicorn "
"-w {workers} "
"--timeout {timeout} "
"-b {address}:{port} "
"-b " + addr_str +
"--limit-request-line 0 "
"--limit-request-field_size 0 "
"superset:app").format(**locals())