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抓取京东价格分析京东商品价格走势
Jan 09 Python
python的迭代器与生成器实例详解
Jul 16 Python
极简的Python入门指引
Apr 01 Python
Python选择排序、冒泡排序、合并排序代码实例
Apr 10 Python
动感网页相册 python编写简单文件夹内图片浏览工具
Aug 17 Python
Python实现小数转化为百分数的格式化输出方法示例
Sep 20 Python
Python解决两个整数相除只得到整数部分的实例
Nov 10 Python
对Python3中bytes和HexStr之间的转换详解
Dec 04 Python
python3使用pandas获取股票数据的方法
Dec 22 Python
Python设计模式之外观模式实例详解
Jan 17 Python
Python Tornado批量上传图片并显示功能
Mar 26 Python
PyQt5 文本输入框自动补全QLineEdit的实现示例
May 13 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 session有效期session.gc_maxlifetime
2011/04/20 PHP
openflashchart 2.0 简单案例php版
2012/05/21 PHP
PHP使用Pthread实现的多线程操作实例
2015/11/14 PHP
PHP中header函数的用法及其注意事项详解
2016/06/13 PHP
Javascript中 关于prototype属性实现继承的原理图
2013/04/16 Javascript
js中如何复制一个对象并获取其所有属性和属性对应的值
2013/10/24 Javascript
如何用JavaScript定义一个类
2014/09/12 Javascript
使用struts2+Ajax+jquery验证用户名是否已被注册
2016/03/22 Javascript
canvas实现图片根据滑块放大缩小效果
2017/02/24 Javascript
基于node.js之调试器详解
2017/08/22 Javascript
weui框架实现上传、预览和删除图片功能代码
2017/08/24 Javascript
AngularJS中filter的使用实例详解
2017/08/25 Javascript
Vue表单输入绑定的示例代码
2018/11/01 Javascript
微信小程序中悬浮窗功能的实现代码
2019/08/02 Javascript
js实现无缝轮播图效果
2020/03/09 Javascript
js实现页面图片消除效果
2020/03/24 Javascript
Python函数学习笔记
2008/10/07 Python
Python深入学习之特殊方法与多范式
2014/08/31 Python
pytorch + visdom CNN处理自建图片数据集的方法
2018/06/04 Python
python实现飞机大战微信小游戏
2020/03/21 Python
对python遍历文件夹中的所有jpg文件的实例详解
2018/12/08 Python
详解Python time库的使用
2019/10/10 Python
pytorch GAN伪造手写体mnist数据集方式
2020/01/10 Python
From CSV to SQLite3 by python 导入csv到sqlite实例
2020/02/14 Python
Pytorch mask_select 函数的用法详解
2020/02/18 Python
关于win10在tensorflow的安装及在pycharm中运行步骤详解
2020/03/16 Python
使用CSS3配合IE滤镜实现渐变和投影的效果
2015/09/06 HTML / CSS
澳大利亚最好的电动自行车:Leon Cycle
2020/12/19 全球购物
毕业生的自我鉴定
2013/10/29 职场文书
护理学中专毕业生求职信
2013/11/11 职场文书
办公室人员先进事迹
2014/01/27 职场文书
十八大感想感言
2014/02/10 职场文书
《美丽的小路》教学反思
2014/02/26 职场文书
小学教师师德演讲稿
2014/05/06 职场文书
2016年国庆节67周年活动总结
2016/04/01 职场文书
详细介绍Java中的CyclicBarrier
2022/04/13 Java/Android