From a078a462993ed98a730dd3c13f33ef09a773cf8f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 17 May 2017 15:08:50 -0400 Subject: [PATCH] meinheld --- Pipfile | 1 + README.md | 16 ++++++++-------- flask_common.py | 2 +- setup.py | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Pipfile b/Pipfile index f9351cf..1eaa8e4 100644 --- a/Pipfile +++ b/Pipfile @@ -10,3 +10,4 @@ crayons = "*" maya = "*" Flask-Compress = "*" Flask-Cache = "*" +meinheld = "*" diff --git a/README.md b/README.md index 7e9cc2d..985d0ba 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ if __name__ == "__main__": common.serve() ``` -Next: +Next: -- Put a `favicon.ico` in your `static` folder. +- Put a `favicon.ico` in your `static` folder. - Enjoy! ## Nicities @@ -39,17 +39,17 @@ HTTP Headers: Other nice things: -- `@common.cache.cached(timeout=50)` decorator for caching views in memory. +- `@common.cache.cached(timeout=50)` decorator for caching views in memory. - Favicon support (`/favicon.ico` redirects to `/static/favicon.ico`). -## Web Server: Gunicorn +## Web Server: Gunicorn + Meinheld -Automatically uses Gunicorn for production (when `Flask.debug = False`), Flask's dev server for development. +Automatically uses Gunicorn + Meinheld for production (when `Flask.debug = False`), Flask's dev server for development. Configuration environment variables: -- `WEB_CONCURRENCY` for specifying the number of synchronous gunicorn workers. -- `PORT` for binding to a specific port. +- `WEB_CONCURRENCY` for specifying the number of synchronous gunicorn workers. +- `PORT` for binding to a specific port. ## File Server: WhiteNoise @@ -60,4 +60,4 @@ Flask-Common automatically configures [WhiteNoise](http://whitenoise.evans.io) t app.config['COMMON_FILESERVER_DISABLED'] = 1 app.config['COMMON_POWERED_BY_DISABLED'] = 1 app.config['COMMON_PROCESSED_TIME_DISABLED'] = 1 - + diff --git a/flask_common.py b/flask_common.py index e433920..d4f26e5 100644 --- a/flask_common.py +++ b/flask_common.py @@ -140,6 +140,6 @@ class Common(object): print(crayons.yellow('Booting Gunicorn...')) # Start the web server. - server = GunicornServer(self.app, workers=workers or number_of_gunicorn_workers(), **kwargs) + server = GunicornServer(self.app, workers=workers or number_of_gunicorn_workers(), worker_class='egg:meinheld#gunicorn_worker', **kwargs) server.run() diff --git a/setup.py b/setup.py index d846cb2..e87cd97 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,8 @@ setup( 'WhiteNoise', 'crayons', 'maya', - 'flask_cache' + 'flask_cache', + 'meinheld' ], classifiers=[ 'Environment :: Web Environment',