gunicorn 啓動django

 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 cloud.fxeye.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";
}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章