在uwsgi得配置文件内增加:
enable-threads = true
preload=true
lazy-apps=true
因为uwsgi默认一个线程一个处理器,所以在没有请求时,线程是被挂起得
完整的配置文件:
[uwsgi]
# 通过浏览器可以访问的模式,使用的协议为http/https
http=0.0.0.0:20001
# 通过浏览器不可以访问,必须通过代理访问,使用的协议不是http类型
#socket = 127.0.0.1:4000
#虚拟环境中的目录,这里env后边不要/bin
home = /mnt/wxgk_py/wxgk_env
#启动的文件
wsgi-file = /mnt/wxgk_py/code/lns_ssh/app.py
# python 程序内用以启动的 application 变量名,不加callable=app,访问时报服务器错误Internal Server Error
callable=app
# 处理器数
processes = 1
# 线程数
threads = 1
buffer-size = 32768
master = true
stats= /mnt/wxgk_py/code/uwsgi/log/uwsgi_lns.status
# 保存启动之后主进程的pid
pidfile= /mnt/wxgk_py/code/uwsgi/log/uwsgi_lns.pid
# 后台运行时记录uwsgi的运行日志
daemonize = /mnt/wxgk_py/code/uwsgi/log/uwsgi_lns.log
# 解决uwsgi全局变量不可用问题
# uwsgi默认one thread one processor,所以在没有请求时,部分进程会被挂起
enable-threads = true
preload=true
lazy-apps=true