一: gunicorn安装与启动
- 1: 安装对应的异步模块
- 2: 安装gunicorn
- 3: 命令方式启动项目:
- gunicorn -w 进程数量 -b 域名:端口 启动文件名:应用名
- 4: 配置文件方式启动项目
- gunicorn -c 配置文件名 启动文件名:应用名
二:gunicorn配置文件
import multiprocessing
workers = multiprocessing.cpu_count() * 2 + 1
threads = 3
bind = '127.0.0.1:5000'
daemon = 'false'
worker_class = 'gevent'
worker_connections = 2000
pidfile = './run/gunicorn.pid'
accesslog = './logs/gunicorn_access.log'
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
errorlog = './logs/gunicorn_error.log'
loglevel = 'warning'
raw_env = 'FLASK_DEBUG=0'
pythonpath='/Users/kj/Desktop/python_env/nowlewdge_env/bin/python'
keepalive = 3
limit_request_field_size = 8190
limit_request_fields = 101
limit_request_line = 5120
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
三:常用的查看命令:
- 1: 查看gunicorn启动项目的主进程号: cat ./run/gunicorn.pid
- 2: 查看主进程之外的进程: