Skip to content

Commit

Permalink
Using gunicorn instead of Tornada as the production wsgi server
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 10, 2015
1 parent 5760c4f commit 63d4f8e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
20 changes: 12 additions & 8 deletions airflow/bin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,20 @@ def webserver(args):
print(settings.HEADER)
log_to_stdout()
from airflow.www.app import app
threads = args.threads or conf.get('webserver', 'threads')
if args.debug:
print(
"Starting the web server on port {0} and host {1}.".format(
args.port, args.hostname))
app.run(debug=True, port=args.port, host=args.hostname)
else:
print(
'Running Tornado server on host {host} and port {port}...'.format(
host=args.hostname, port=args.port))
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(args.port)
IOLoop.instance().start()
'Running the Gunicorn server with {threads}'
'on host {args.hostname} and port '
'{args.port}...'.format(**locals()))
subprocess.Popen([
'gunicorn', '-w', str(args.threads), '-b',
args.hostname + ':' + str(args.port), 'airflow.www.app:app'])


def scheduler(args):
Expand Down Expand Up @@ -487,6 +486,11 @@ def get_parser():
default=conf.get('webserver', 'WEB_SERVER_PORT'),
type=int,
help="Set the port on which to run the web server")
parser_webserver.add_argument(
"-w", "--threads",
default=conf.get('webserver', 'THREADS'),
type=int,
help="Number of threads to run the webserver on")
parser_webserver.add_argument(
"-hn", "--hostname",
default=conf.get('webserver', 'WEB_SERVER_HOST'),
Expand Down
4 changes: 4 additions & 0 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class AirflowConfigException(Exception):
'demo_mode': False,
'secret_key': 'airflowified',
'expose_config': False,
'threads': 4,
},
'scheduler': {
'statsd_on': False,
Expand Down Expand Up @@ -127,6 +128,9 @@ class AirflowConfigException(Exception):
# Secret key used to run your flask app
secret_key = temporary_key
# number of threads to run the Gunicorn web server
thread = 4
# Expose the configuration file in the web server
expose_config = true
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ flask-cache
flask-login
flower
future
gunicorn
hive-thrift-py
ipython
jinja2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'flask-login>=0.2.11',
'flower>=0.7.3',
'future>=0.15.0',
'gunicorn>=19.3.0',
'jinja2>=2.7.3',
'markdown>=2.5.2',
'pandas>=0.15.2',
Expand All @@ -61,7 +62,6 @@
'sqlalchemy>=0.9.8',
'statsd>=3.0.1',
'thrift>=0.9.2',
'tornado>=4.0.2',
],
extras_require={
'all': devel + optional,
Expand Down

0 comments on commit 63d4f8e

Please sign in to comment.