Gunicorn 配置文件

# gunicorn.py
import logging
import logging.handlers
from logging.handlers import WatchedFileHandler
import os
import multiprocessing
import gevent.monkey
gevent.monkey.patch_all()

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
# bind = '0.0.0.0:5000'  # 綁定ip和端口號(hào)
backlog = 512  # 監(jiān)聽隊(duì)列
chdir = BASE_DIR  # gunicorn要切換到的目的工作目錄
timeout = 30  # 超時(shí)
worker_class = 'gevent'  # 使用gevent模式,還可以使用sync 模式,默認(rèn)的是sync模式

# workers = multiprocessing.cpu_count()  # 進(jìn)程數(shù)
workers = multiprocessing.cpu_count() + 1  # 進(jìn)程數(shù)
threads = 2  # 指定每個(gè)進(jìn)程開啟的線程數(shù)
loglevel = 'warning'  # 日志級(jí)別,這個(gè)日志級(jí)別指的是錯(cuò)誤日志的級(jí)別,而訪問日志的級(jí)別無法設(shè)置
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'  # 設(shè)置gunicorn訪問日志格式,錯(cuò)誤日志無法設(shè)置

"""
其每個(gè)選項(xiàng)的含義如下:
h          remote address
l          '-'
u          currently '-', may be user name in future releases
t          date of the request
r          status line (e.g. ``GET / HTTP/1.1``)
s          status
b          response length or '-'
f          referer
a          user agent
T          request time in seconds
D          request time in microseconds
L          request time in decimal seconds
p          process ID
"""
accesslog = os.path.join(BASE_DIR, "log/gunicorn_access.log")  # 訪問日志文件
errorlog = os.path.join(BASE_DIR, "log/gunicorn_error.log")  # 錯(cuò)誤日志文件


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容