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中实现贪婪排名算法的教程
Apr 17 Python
Python scikit-learn 做线性回归的示例代码
Nov 01 Python
Django 根据数据模型models创建数据表的实例
May 27 Python
浅谈django rest jwt vue 跨域问题
Oct 26 Python
Python3+PyInstall+Sciter解决报错缺少dll、html等文件问题
Jul 15 Python
pycharm修改文件的默认打开方式的步骤
Jul 29 Python
python的移位操作实现详解
Aug 21 Python
opencv 图像腐蚀和图像膨胀的实现
Jul 07 Python
解决import tensorflow导致jupyter内核死亡的问题
Feb 06 Python
python opencv实现图像配准与比较
Feb 09 Python
Python 把两层列表展开平铺成一层(5种实现方式)
Apr 07 Python
Python如何快速找到多个字典中的公共键(key)
Apr 29 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导出带样式的Excel示例代码
2016/08/28 PHP
PHP会员找回密码功能的简单实现
2016/09/05 PHP
Yii2设置默认控制器的两种方法
2017/05/19 PHP
对php 判断http还是https,以及获得当前url的方法详解
2019/01/15 PHP
Yii框架学习笔记之应用组件操作示例
2019/11/13 PHP
让iframe框架网页在任何浏览器下自动伸缩
2006/08/18 Javascript
javascript 写的一个简单的timer
2009/07/30 Javascript
Mootools 1.2教程 定时器和哈希简介
2009/09/15 Javascript
jQuery EasyUI API 中文文档 - DataGrid数据表格
2011/11/17 Javascript
IE6-8中Date不支持toISOString的修复方法
2014/05/04 Javascript
js实现回放拖拽轨迹从过程上进行分析
2014/06/26 Javascript
JavaScript检测浏览器cookie是否已经启动的方法
2015/02/27 Javascript
JavaScript如何动态创建table表格
2020/08/02 Javascript
使用堆实现Top K算法(JS实现)
2015/12/25 Javascript
jquery.uploadifive插件怎么解决上传限制图片或文件大小问题
2017/05/08 jQuery
Javascript中Promise的四种常用方法总结
2017/07/14 Javascript
vue axios用法教程详解
2017/07/23 Javascript
浅谈Angular路由复用策略
2017/10/04 Javascript
Vue2.0 实现单选互斥的方法
2018/04/13 Javascript
JSX在render函数中的应用详解
2019/09/04 Javascript
原生js实现贪食蛇小游戏的思路详解
2019/11/26 Javascript
Python2.x版本中基本的中文编码问题解决
2015/10/12 Python
python xml解析实例详解
2016/11/14 Python
Python 操作MySQL详解及实例
2017/04/30 Python
Python 结巴分词实现关键词抽取分析
2017/10/21 Python
python递归全排列实现方法
2018/08/18 Python
Python 串口读写的实现方法
2019/06/12 Python
wxPython电子表格功能wx.grid实例教程
2019/11/19 Python
python图形界面开发之wxPython树控件使用方法详解
2020/02/24 Python
django自带的权限管理Permission用法说明
2020/05/13 Python
学python需要去培训机构吗
2020/07/01 Python
C++和python实现阿姆斯特朗数字查找实例代码
2020/12/07 Python
商务英语专业毕业生自荐信
2013/11/05 职场文书
临床护理求职信
2014/04/26 职场文书
县政府领导班子“四风”方面突出问题整改措施
2014/09/23 职场文书
SpringCloud的JPA连接PostgreSql的教程
2021/06/26 Java/Android