gunicorn.conf.py
import logging
import logging.handlers
from logging.handlers import WatchedFileHandler
import os
import multiprocessing
bind = "127.0.0.1:8000" #绑定的ip与端口
backlog = 512 #监听队列数量,64-2048
worker_class = 'sync' #使用gevent模式,还可以使用sync 模式,默认的是sync模式
workers = 4 # multiprocessing.cpu_count() #进程数
threads = 16 #multiprocessing.cpu_count()*4 #指定每个进程开启的线程数
loglevel = 'info' #日志级别,这个日志级别指的是错误日志的级别,而访问日志的级别无法设置
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
accesslog = "-" #访问日志文件,"-" 表示标准输出
errorlog = "-" #错误日志文件,"-" 表示标准输出
proc_name = 'eashop' #进程名
启动命令:
/root/python/bin/gunicorn -c gunicorn.conf.py EA_Shop.wsgi:application
#EA_Shop 是有wsgi.py的目录层次
nginx.conf
server {
listen 80;
server_name xxx.xxx.com;
client_max_body_size 50m;
location /static {
alias /*/static/;
}
location / {
proxy_set_header x-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8000;
#include uwsgi_params;
#uwsgi_pass 127.0.0.1:8000;
#proxy_pass_header Server;
##### 支持websocket
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}