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创建列表并给列表赋初始值的方法
Jul 28 Python
python实现实时监控文件的方法
Aug 26 Python
Django数据库表反向生成实例解析
Feb 06 Python
python中找出numpy array数组的最值及其索引方法
Apr 17 Python
PyQt5每天必学之带有标签的复选框
Apr 19 Python
Python实现抓取HTML网页并以PDF文件形式保存的方法
May 08 Python
python实践项目之监控当前联网状态详情
May 23 Python
详解使用PyInstaller将Pygame库编写的小游戏程序打包为exe文件
Aug 23 Python
对Pytorch中Tensor的各种池化操作解析
Jan 03 Python
Python龙贝格法求积分实例
Feb 29 Python
利用Python如何画一颗心、小人发射爱心
Feb 21 Python
Python echarts实现数据可视化实例详解
Mar 03 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
espresso double下 咖啡粉超细时 饼压力对咖啡的影响
2021/03/03 冲泡冲煮
thinkPHP的Html模板标签使用方法
2012/11/13 PHP
thinkphp3.0输出重复两次的解决方法
2014/12/19 PHP
PHP实现事件机制的方法
2015/07/10 PHP
js获取URL的参数的方法(getQueryString)示例
2013/09/29 Javascript
js如何获取兄弟、父类等节点
2014/01/06 Javascript
javascript将异步校验表单改写为同步表单
2015/01/27 Javascript
总结十个Angular.js由浅入深的面试问题
2016/08/26 Javascript
浅谈javascript中执行环境(作用域)与作用域链
2016/12/08 Javascript
微信小程序 解决请求服务器手机预览请求不到数据的方法
2017/01/04 Javascript
JS实现商品筛选功能
2020/08/19 Javascript
input 标签实现输入框带提示文字效果(两种方法)
2017/10/09 Javascript
微信公众号获取用户地理位置并列出附近的门店的示例代码
2019/07/25 Javascript
VUE实时监听元素距离顶部高度的操作
2020/07/29 Javascript
详解JavaScript自定义函数
2020/07/29 Javascript
[05:14]辉夜杯主赛事第二日 RECAP精彩回顾
2015/12/27 DOTA
python实现爬虫下载美女图片
2015/07/14 Python
Python排序算法实例代码
2017/08/10 Python
解决Python中定时任务线程无法自动退出的问题
2019/02/18 Python
python笔记_将循环内容在一行输出的方法
2019/08/08 Python
python多线程实现TCP服务端
2019/09/03 Python
基于keras输出中间层结果的2种实现方式
2020/01/24 Python
Python Excel vlookup函数实现过程解析
2020/06/22 Python
keras 自定义loss层+接受输入实例
2020/06/28 Python
详解使用Python写一个向数据库填充数据的小工具(推荐)
2020/09/11 Python
HTML5头部标签的一些常用信息小结
2016/10/23 HTML / CSS
HTML5 canvas实现的静态循环滚动播放弹幕
2021/01/05 HTML / CSS
Hertz荷兰:荷兰和全球租车
2018/01/07 全球购物
英国老牌潮鞋店:Offspring
2019/08/19 全球购物
师范生实习的个人自我鉴定
2013/10/20 职场文书
初一生物教学反思
2014/01/18 职场文书
超市理货员岗位职责
2014/07/04 职场文书
乡党委干部党的群众路线教育实践活动个人对照检查材料思想汇报
2014/10/01 职场文书
新店开业策划方案怎么书写?
2019/07/05 职场文书
教师实习自我鉴定总结
2019/08/20 职场文书
Python OpenCV 彩色与灰度图像的转换实现
2021/06/05 Python