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启动办公软件进程(word、excel、ppt、以及wps的et、wps、wpp)
Apr 09 Python
Python中splitlines()方法的使用简介
May 20 Python
python中is与双等于号“==”的区别示例详解
Nov 21 Python
Python中装饰器高级用法详解
Dec 25 Python
Python3.6笔记之将程序运行结果输出到文件的方法
Apr 22 Python
解决Python 爬虫URL中存在中文或特殊符号无法请求的问题
May 11 Python
Python 3.x基于Xml数据的Http请求方法
Dec 28 Python
python ipset管理 增删白名单的方法
Jan 14 Python
用python3 urllib破解有道翻译反爬虫机制详解
Aug 14 Python
通用的Django注册功能模块实现方法
Feb 05 Python
python实现Thrift服务端的方法
Apr 20 Python
Python的三个重要函数详解
Jan 18 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 一个页面执行时间类代码
2010/03/05 PHP
php遍历文件夹所有文件子文件夹函数代码
2013/11/27 PHP
常用PHP框架功能对照表
2014/10/23 PHP
php函数serialize()与unserialize()用法实例
2014/11/06 PHP
php判断两个浮点数是否相等的方法
2015/03/14 PHP
PHP中PDO的事务处理分析
2016/04/07 PHP
深入理解Yii2.0乐观锁与悲观锁的原理与使用
2017/07/26 PHP
PHP registerXPathNamespace()函数讲解
2019/02/03 PHP
超级退弹代码
2008/07/07 Javascript
JavaScript window.document的属性、方法和事件小结
2012/10/24 Javascript
jquery ajax 简单范例(界面+后台)
2013/11/19 Javascript
打造个性化的功能强大的Jquery虚拟键盘(VirtualKeyboard)
2014/10/11 Javascript
JS实现固定在右下角可展开收缩DIV层的方法
2015/02/13 Javascript
Angular.JS实现无限级的联动菜单(使用demo)
2017/02/08 Javascript
浅谈Vue Element中Select下拉框选取值的问题
2018/03/01 Javascript
js实现导航跟随效果
2018/11/17 Javascript
JS数组中对象去重操作示例
2019/06/04 Javascript
JS实现iframe中子父页面跨域通讯的方法分析
2020/03/10 Javascript
浅谈webpack构建工具配置和常用插件总结
2020/05/11 Javascript
[14:36]2014 DOTA2国际邀请赛中国区预选赛5.21 Orenda VS NE
2014/05/22 DOTA
通过数据库对Django进行删除字段和删除模型的操作
2015/07/21 Python
Python编程之序列操作实例详解
2017/07/22 Python
快速了解Python相对导入
2018/01/12 Python
python清除字符串前后空格函数的方法
2018/10/21 Python
Python图像处理实现两幅图像合成一幅图像的方法【测试可用】
2019/01/04 Python
python判断字符串或者集合是否为空的实例
2019/01/23 Python
Linux上使用Python统计每天的键盘输入次数
2019/04/17 Python
PyQt5图形界面播放音乐的实例
2019/06/17 Python
html5 canvas 实现光线沿不规则路径运动
2020/04/20 HTML / CSS
捷克家居装饰及图书音像购物网站:Velký košík
2018/04/16 全球购物
12岁生日演讲稿
2014/05/14 职场文书
2014年感恩母亲演讲稿
2014/05/27 职场文书
无房产证房屋转让协议书合同样本
2014/10/18 职场文书
2014年机关党建工作总结
2014/11/11 职场文书
2014年社区工会工作总结
2014/12/18 职场文书
2015年世界无烟日活动总结
2015/02/10 职场文书