Add documentation for Gunicorn worker

This commit is contained in:
messense 2017-03-23 09:12:23 +08:00
parent 1456b128d2
commit 3d9927dee0
No known key found for this signature in database
GPG Key ID: BB41A8A2C716CCA9

View File

@ -44,3 +44,15 @@ directly run by the interpreter.
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=1337, workers=4) app.run(host='0.0.0.0', port=1337, workers=4)
``` ```
## Running via Gunicorn
[Gunicorn](http://gunicorn.org/) Green Unicorn is a WSGI HTTP Server for UNIX.
Its a pre-fork worker model ported from Rubys Unicorn project.
In order to run Sanic application with Gunicorn, you need to use the special `sanic.worker.GunicornWorker`
for Gunicorn `worker-class` argument:
```
gunicorn --bind 0.0.0.0:1337 --worker-class sanic.worker.GunicornWorker
```