gunicorn 調試功能


dash-gun.py


accesslog = "./log/dash_acess.log" # 請求 errorlog = './log/dash_error.log'  # 錯誤 loglevel = 'debug'            # debug 模式 reload = True               # 修改代碼自動重啟

 

運行(我運行的是flask)

gunicorn --config dash-gun.py -b 0.0.0.0:5555 'app:public()'

 

這樣在控制台會輸出一些 print 信息

在 dash_error.log 中可以看到一些請求和報錯

在 dash_acess.log 中是詳細的請求

可以使用 tail 命令動態查看

tail -10f dash_error.log

 

 

貼一個完整的配置:

dash-run-test.sh # 運行文件

#!/bin/sh
# 進入虛擬環境
source /www/wwwroot/default/env/bin/activate

# export FLASK_APP=app:dash
# flask run -p 5558

#gunicorn --log-level=info -b 0.0.0.0:5558 'app:dash()'
gunicorn 'app:dash()' -c config/gunicorn/dash-gunicorn-test.py

 配置文件:

#workers=8 # 進程數
#threads = 2 # 工作者的線程數
bind = '0.0.0.0:5560'
daemon = 'false' # 使用suppervisor 管理  暫時使用nohup
worker_class = "gevent" # 並發
worker_connections = 2000
threads = 20
#pidfile = '/var/run/gunicorn.pid' # 設置進程文件目錄
accesslog = './log/gunicorn/gun_dash_acess.log'
errorlog = './log/gunicorn/gun_dash_error.log'
# 設置日志記錄水平
loglevel = 'warning'
timeout = 6000
#preload_app = True
reload = True

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM