Skip to content

Commit

Permalink
Add UNIX socket option to runserver (#2627)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
joefrancia authored and mistercrunch committed Apr 17, 2017
1 parent 6b1bf3b commit 70c6cad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions superset/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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())
Expand Down

0 comments on commit 70c6cad

Please sign in to comment.