gunicorn

说明

  • uWSGI是实现了WSGI协议的应用程序。

安装

  • pip3 install gunicorn

文档

配置

选项 说明 示例
-w / --works 工作进程 4
-b / --bind 绑定地址 127.0.0.1:5000
-c / --config 指定配置文件 xxx.py / yyy.ini
-D / --daemon 是否后台运行 默认为False,设置即为True
-p / --pid 指定进程文件 xxx.pid
-u / --user 指定用户 test
-g / --group 指定用户组 Test
-t / --timeout 超时时间 30
--threads 线程数 1
--access-logfile 访问日志 access.log
--error-logfile / --log-file 错误日志 error.log
--log-level 日志级别 debug info warning error critical
--chdir 指定程序目录 dir

启动

  • gunicorn -D -w 3 -t 300 -b 127.0.0.1:5000 blog:app

配置文件

  • gunicorn.conf.py
import multiprocessing

# debug = True
loglevel = 'debug'
bind = "127.0.0.1:5000"
pidfile = "log/gunicorn.pid"
accesslog = "log/access.log"
errorlog = "log/debug.log"
daemon = True

# 启动的进程数
workers = multiprocessing.cpu_count()

gunicorn -c gunicorn.conf.py blog:app

  • gunicorn.ini文件
[server:main]
host = 192.168.0.1
port = 80
workers = 2

gunicorn -c gunicorn.ini blog:app

results matching ""

    No results matching ""