1 Introduction
Gunicorn'Green Unicorn' is a WSGI HTTP server under UNIX. It is a pre-fork worker model ported from Ruby's Unicorn project. It supports both eventlet and greenlet
In the management of workers, the pre-fork model is used, that is, a master process manages multiple worker processes, and all requests and responses are processed by the worker. The master process is a simple loop that listens for signals from different processes of the worker and responds. For example, receiving TTIN increases the number of workers, and TTOU reduces the number of running workers. If the worker hangs and a CHLD is issued, the failed worker is restarted, and the synchronized worker processes one request at a time.
2. Installation
At present, Gunicorn can only run in the Linux environment and does not support the windows platform
[jian@laptop ~]$ pip install gunicorn
[jian@laptop ~]$ pip show gunicorn
Name: gunicorn
Version: 19.7.1
Summary: WSGI HTTP Server for UNIX
Home-page: http://gunicorn.org
Author: Benoit Chesneau
Author-email: benoitc@e-engura.com
License: MIT
Location: /home/jian/.pyenv/versions/3.6.7/lib/python3.6/site-packages
Requires:
Required-by:
3. Use
gunicorn -w 4 -b 0.0.0.0:8000 demo:app
The first server refers to the server.py file; the
second refers to the name of the flask application, app = Flask(name)
-w to open n processes