django启动uwsgi报错的解决方法


Posted in Python onApril 08, 2018

uwsgi介绍

uWSGI是一个Web服务器,它实现了WSGI协议、uwsgi、http等协议。Nginx中HttpUwsgiModule的作用是与uWSGI服务器进行交换。

要注意 WSGI / uwsgi / uWSGI 这三个概念的区分。

  • WSGI是一种Web服务器网关接口。它是一个Web服务器(如nginx,uWSGI等服务器)与web应用(如用Flask框架写的程序)通信的一种规范。
  • uwsgi是一种线路协议而不是通信协议,在此常用于在uWSGI服务器与其他网络服务器的数据通信。
  • 而uWSGI是实现了uwsgi和WSGI两种协议的Web服务器。
  • uwsgi协议是一个uWSGI服务器自有的协议,它用于定义传输信息的类型(type of information),每一个uwsgi packet前4byte为传输信息类型描述,它与WSGI相比是两样东西。

uwsgi性能非常高

django启动uwsgi报错的解决方法

最近在django启动uwsgi报错的时候,发现了一些错误,下面来一起看看吧

查看uwsgi.log

*** Starting uWSGI 2.0.17 (64bit) on [Thu Apr 5 17:46:15 2018] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 05 April 2018 02:08:03
os: Linux-2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016
nodename: GDJ_DEV
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /xxx/xxx/xxx/xxx
writing pidfile to uwsgi.pid
detected binary path: /xxx/xxx/.virtualenvs/h1/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /xxx/xxx/xxx/xxx
your processes number limit is 100000
your memory page size is 4096 bytes
detected max file descriptor number: 100000
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 172.21.0.5:8000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:33522 (port auto-assigned) fd 3
Python version: 3.6.4 (default, Mar 24 2018, 10:32:21) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
Python main interpreter initialized at 0x1ff10d0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 416880 bytes (407 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
failed to open python file xxx/uwsgi.ini
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 4865)
spawned uWSGI worker 1 (pid: 4866, cores: 2)
spawned uWSGI worker 2 (pid: 4867, cores: 2)
spawned uWSGI worker 3 (pid: 4868, cores: 2)
spawned uWSGI worker 4 (pid: 4869, cores: 2)
spawned uWSGI http 1 (pid: 4870)
--- no python application found, check your startup logs for errors ---
[pid: 4869|app: -1|req: -1/1] 118.26.10.242 () {40 vars in 777 bytes} [Thu Apr 5 17:46:31 2018] GET /user/login/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

解决第一个报错,注意操作的先后顺序:

1.卸载uwsgi

pip uninstall uwsgi

#注意此时卸载,pip会有缓存留在系统里

2.安装pcre支持库

yum install pcre pcre-devel pcre-static

3.继续安装uwsgi,不走pip缓存

pip install uwsgi -I --no-cache-dir

#启动uwsgi,已经没有“ !!! no internal routing support, rebuild with pcre support !!! ”报错了

解决第二个报错:

需要在你的uwsgi.ini文件中module指定项目下面的wsgi:

module=xxx.wsgi

#注:xxx为项目名称,startproject那个项目名称,这个错误解决后,下面的访问错误自然而然的就解决了!

附:我的uwsgi.ini配置文件

[uwsgi]
#socket=ip:port       #使用nginx代理请求时配置,直接访问uwsgi使用http方式
http=ip:port
chdir=/xxx/xxx       #项目根目录的绝对路径
wsgi-file=xxx/uwsgi.ini  #项目目录下的uwsgi.ini
module=xxx.wsgi      #指向项目下的wsgi模块
processes=4
threads=2
master=True
py-atuo-reload=1
env=DJANGO_SETTINGS_MODULE=xxx.settings
pidfile=uwsgi.pid
daemonize=uwsgi.log

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对三水点靠木的支持。

Python 相关文章推荐
Python中转换角度为弧度的radians()方法
May 18 Python
Python实现线程状态监测简单示例
Mar 28 Python
基于python 二维数组及画图的实例详解
Apr 03 Python
详解Python中的分组函数groupby和itertools)
Jul 11 Python
利用Python将数值型特征进行离散化操作的方法
Nov 06 Python
python提取xml里面的链接源码详解
Oct 15 Python
Python异常模块traceback用法实例分析
Oct 22 Python
python中使用you-get库批量在线下载bilibili视频的教程
Mar 10 Python
Python实现AI换脸功能
Apr 10 Python
Django nginx配置实现过程详解
Sep 10 Python
python中pop()函数的语法与实例
Dec 01 Python
详解Python+Selenium+ChromeDriver的配置和问题解决
Jan 19 Python
python 2.7.14安装图文教程
Apr 08 #Python
详解Python中的动态属性和特性
Apr 07 #Python
简单谈谈Python的pycurl模块
Apr 07 #Python
VSCode下好用的Python插件及配置
Apr 06 #Python
VScode编写第一个Python程序HelloWorld步骤
Apr 06 #Python
在VS Code上搭建Python开发环境的方法
Apr 06 #Python
python装饰器深入学习
Apr 06 #Python
You might like
收音机鉴频器对声音的影响和频偏分析
2021/03/02 无线电
PHP4实际应用经验篇(9)
2006/10/09 PHP
PHP中浮点数计算比较及取整不准确的解决方法
2015/01/09 PHP
PHP设计模式之工厂方法设计模式实例分析
2018/04/25 PHP
优秀js开源框架-jQuery使用手册(1)
2007/03/10 Javascript
Javascript学习笔记1 数据类型
2010/01/11 Javascript
制作高质量的JQuery Plugin 插件的方法
2010/04/20 Javascript
基于jquery的时间段实现代码
2012/08/02 Javascript
js中浮点型运算BUG的解决方法说明
2014/01/06 Javascript
用js提交表单解决一个页面有多个提交按钮的问题
2014/09/01 Javascript
浅谈JavaScript实现面向对象中的类
2014/12/09 Javascript
jQuery实现移动 和 渐变特效的点击事件
2015/02/26 Javascript
JS判断当前页面是否在微信浏览器打开的方法
2015/12/08 Javascript
JavaScript数组的栈方法与队列方法详解
2016/05/26 Javascript
Three.js开发实现3D地图的实践过程总结
2017/11/20 Javascript
jQuery扩展方法实现Form表单与Json互相转换的实例代码
2018/09/05 jQuery
vue props对象validator自定义函数实例
2019/11/13 Javascript
微信小程序连续签到7天积分获得功能的示例代码
2020/08/20 Javascript
分析Python的Django框架的运行方式及处理流程
2015/04/08 Python
python获得linux下所有挂载点(mount points)的方法
2015/04/29 Python
Python实现的简单hangman游戏实例
2015/06/28 Python
PyQt4实现下拉菜单可供选择并打印出来
2018/04/20 Python
python docx 中文字体设置的操作方法
2018/05/08 Python
python初学者,用python实现基本的学生管理系统(python3)代码实例
2019/04/10 Python
Python求均值,方差,标准差的实例
2019/06/29 Python
使用python检查yaml配置文件是否符合要求
2020/04/09 Python
keras 读取多标签图像数据方式
2020/06/12 Python
里程积分管理买卖交换平台:Points.com
2017/01/13 全球购物
Tarte Cosmetics官网:美国最受欢迎的化妆品公司之一
2017/08/24 全球购物
大专自我鉴定范文
2013/10/01 职场文书
新学期决心书
2014/03/11 职场文书
艺术节主持词
2014/04/02 职场文书
教育系统干部作风整顿心得体会
2014/09/09 职场文书
因个人原因离职的辞职信范文
2015/05/12 职场文书
2015年小学辅导员工作总结
2015/05/27 职场文书
Pandas 数据编码的十种方法
2022/04/20 Python