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