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抓taobao图片爬虫
Oct 26 Python
Django imgareaselect手动剪切头像实现方法
May 26 Python
举例讲解如何在Python编程中进行迭代和遍历
Jan 19 Python
Python将图片批量从png格式转换至WebP格式
Aug 22 Python
实现python版本的按任意键继续/退出
Sep 26 Python
python中format()函数的简单使用教程
Mar 14 Python
如何利用Boost.Python实现Python C/C++混合编程详解
Nov 08 Python
Python rstrip()方法实例详解
Nov 11 Python
Python基础之循环语句用法示例【for、while循环】
Mar 23 Python
Python数组拼接np.concatenate实现过程
Apr 18 Python
Python+PyQt5实现灭霸响指功能
May 25 Python
在Keras中利用np.random.shuffle()打乱数据集实例
Jun 15 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
php 8小时时间差的解决方法小结
2009/12/22 PHP
fleaphp crud操作之find函数的使用方法
2011/04/23 PHP
php自定义函数实现JS的escape的方法示例
2016/07/07 PHP
使用PHP+MySql实现微信投票功能实例代码
2017/09/29 PHP
PHP goto语句用法实例
2019/08/06 PHP
php获取微信openid方法总结
2019/10/10 PHP
JavaScript 组件之旅(四):测试 JavaScript 组件
2009/10/28 Javascript
JS OOP包机制,类创建的方法定义
2009/11/02 Javascript
javascrip客户端验证文件大小及文件类型并重置上传
2011/01/12 Javascript
javascript小数四舍五入多种方法实现
2012/12/23 Javascript
AngularJS 避繁就简的路由
2016/07/01 Javascript
vue.js通过自定义指令实现数据拉取更新的实现方法
2016/10/18 Javascript
Javascript this 函数深入详解
2016/12/13 Javascript
JS 实现 ajax 异步浏览器兼容问题
2017/01/21 Javascript
ECMAscript 变量作用域总结概括
2017/08/18 Javascript
vue2.0移动端滑动事件vue-touch的实例代码
2018/11/27 Javascript
npm 常用命令详解(小结)
2019/01/17 Javascript
vue-cli脚手架引入弹出层layer插件的几种方法
2019/06/24 Javascript
[00:33]2016完美“圣”典风云人物:Sccc宣传片
2016/12/03 DOTA
[41:08]TNC vs VG 2018国际邀请赛小组赛BO2 第一场 8.16
2018/08/17 DOTA
Django imgareaselect手动剪切头像实现方法
2015/05/26 Python
详解在Python程序中解析并修改XML内容的方法
2015/11/16 Python
深入解析Python中的线程同步方法
2016/06/14 Python
django ajax json的实例代码
2018/05/29 Python
python Django中models进行模糊查询的示例
2019/07/18 Python
Django中使用session保持用户登陆连接的例子
2019/08/06 Python
使用Python-OpenCV消除图像中孤立的小区域操作
2020/07/05 Python
matplotlib设置颜色、标记、线条,让你的图像更加丰富(推荐)
2020/09/25 Python
html5简单示例_动力节点Java学院整理
2017/07/07 HTML / CSS
美国知名珠宝首饰品牌:Gemvara
2017/10/06 全球购物
实习教师个人的自我评价
2013/11/08 职场文书
合伙经营协议书范本
2014/04/18 职场文书
传承焦裕禄精神思想汇报2014
2014/09/10 职场文书
孔繁森观后感
2015/06/10 职场文书
jquery插件实现悬浮的菜单
2021/04/24 jQuery
python绘制简单直方图(质量分布图)的方法
2022/04/21 Python