django启动uwsgi报错的解决方法
框架(架构)  /  管理员 发布于 5年前   344
uwsgi介绍
uWSGI是一个Web服务器,它实现了WSGI协议、uwsgi、http等协议。Nginx中HttpUwsgiModule的作用是与uWSGI服务器进行交换。
要注意 WSGI / uwsgi / uWSGI 这三个概念的区分。
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:03os: Linux-2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016nodename: GDJ_DEVmachine: x86_64clock source: unixdetected number of CPU cores: 1current working directory: /xxx/xxx/xxx/xxxwriting pidfile to uwsgi.piddetected binary path: /xxx/xxx/.virtualenvs/h1/bin/uwsgi!!! no internal routing support, rebuild with pcre support !!!chdir() to /xxx/xxx/xxx/xxxyour processes number limit is 100000your memory page size is 4096 bytesdetected max file descriptor number: 100000lock engine: pthread robust mutexesthunder lock: disabled (you can enable it with --thunder-lock)uWSGI http bound on 172.21.0.5:8000 fd 4uwsgi socket 0 bound to TCP address 127.0.0.1:33522 (port auto-assigned) fd 3Python 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 0x1ff10d0python threads support enabledyour server socket listen backlog is limited to 100 connectionsyour mercy for graceful operations on workers is 60 secondsmapped 416880 bytes (407 KB) for 8 cores*** Operational MODE: preforking+threaded ***failed to open python file xxx/uwsgi.iniunable 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:portchdir=/xxx/xxx #项目根目录的绝对路径wsgi-file=xxx/uwsgi.ini #项目目录下的uwsgi.inimodule=xxx.wsgi #指向项目下的wsgi模块processes=4threads=2master=Truepy-atuo-reload=1env=DJANGO_SETTINGS_MODULE=xxx.settingspidfile=uwsgi.piddaemonize=uwsgi.log
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对AIDI的支持。
123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号