Skip to content

Commit

Permalink
Merge pull request apache#1257 from airbnb/ddavydov/configurable_guni…
Browse files Browse the repository at this point in the history
…corn_timeout

[webserver] Make webserver worker timeout configurable
  • Loading branch information
bolkedebruin committed Mar 30, 2016
2 parents 91449a2 + d5074f8 commit 79c0e06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions airflow/bin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def webserver(args):
from airflow.www.app import cached_app
app = cached_app(conf)
workers = args.workers or conf.get('webserver', 'workers')
worker_timeout = (args.worker_timeout or
conf.get('webserver', 'webserver_worker_timeout'))
if args.debug:
print(
"Starting the web server on port {0} and host {1}.".format(
Expand All @@ -345,10 +347,10 @@ def webserver(args):
print(
'Running the Gunicorn server with {workers} {args.workerclass}'
'workers on host {args.hostname} and port '
'{args.port}...'.format(**locals()))
'{args.port} with a timeout of {worker_timeout}...'.format(**locals()))
sp = subprocess.Popen([
'gunicorn', '-w', str(args.workers), '-k', str(args.workerclass),
'-t', '120', '-b', args.hostname + ':' + str(args.port),
'-t', str(args.worker_timeout), '-b', args.hostname + ':' + str(args.port),
'airflow.www.app:cached_app()'])
sp.wait()

Expand Down Expand Up @@ -561,6 +563,11 @@ class CLIFactory(object):
default=conf.get('webserver', 'WORKER_CLASS'),
choices=['sync', 'eventlet', 'gevent', 'tornado'],
help="The worker class to use for gunicorn"),
'worker_timeout': Arg(
("-t", "--worker_timeout"),
default=conf.get('webserver', 'WEB_SERVER_WORKER_TIMEOUT'),
type=int,
help="The timeout for waiting on webserver workers"),
'hostname': Arg(
("-hn", "--hostname"),
default=conf.get('webserver', 'WEB_SERVER_HOST'),
Expand Down Expand Up @@ -683,7 +690,8 @@ class CLIFactory(object):
}, {
'func': webserver,
'help': "Start a Airflow webserver instance",
'args': ('port', 'workers', 'workerclass', 'hostname', 'debug'),
'args': ('port', 'workers', 'workerclass', 'worker_timeout', 'hostname',
'debug'),
}, {
'func': resetdb,
'help': "Burn down and rebuild the metadata database",
Expand Down
4 changes: 4 additions & 0 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def run_command(command):
'base_url': 'http://localhost:8080',
'web_server_host': '0.0.0.0',
'web_server_port': '8080',
'web_server_worker_timeout': 120,
'authenticate': False,
'filter_by_owner': False,
'demo_mode': False,
Expand Down Expand Up @@ -217,6 +218,9 @@ def run_command(command):
# The port on which to run the web server
web_server_port = 8080
# The time the gunicorn webserver waits before timing out on a worker
web_server_worker_timeout = 120
# Secret key used to run your flask app
secret_key = temporary_key
Expand Down

0 comments on commit 79c0e06

Please sign in to comment.