解决思路:no python application found, check your startup logs for errors

uwsgi部署python web项目的时候可能会出现标题报错:

解决思路,看日志:

[root@lovecat uswgi]# uwsgi --http :9090 --wsgi-file /app/uwsgi/start:app
*** Starting uWSGI 2.0.18 (64bit) on [Thu Oct 10 02:28:27 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-36) on 23 September 2019 03:04:11
os: Linux-3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
nodename: lovecat.liu.com
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /app/uswgi
detected binary path: /usr/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 15086
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :9090 fd 4
spawned uWSGI http 1 (pid: 30841)
uwsgi socket 0 bound to TCP address 127.0.0.1:40858 (port auto-assigned) fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 2.7.5 (default, Aug  7 2019, 00:51:29)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x19d4940
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
failed to open python file /app/uwsgi/start:app
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 30840, cores: 1)
--- no python application found, check your startup logs for errors ---
[pid: 30840|app: -1|req: -1/1] 116.228.50.38 () {40 vars in 701 bytes} [Thu Oct 10 02:28:31 2019] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---

 以上是启动一次uwsgi弹出的信息,不要只是等着web请求看请求信息,启动的这么多内容中,包含很多关键信息,包括绝大多数人会忽略的启动失败信息,uwsgi启动错误并不会停止进程,而是会把相关错误直接在启动log中直接打出

上图中就有启动错误信息:

failed to open python file /app/uwsgi/start:app
unable to load app 0 (mountpoint='') (callable not found or import error)

这代表没有打开文件,文件内容不正确导致无法加载。

 

uwsgi启动错误可能有很多种,不是所有的报错我都遇到了,但是错误信息都会在log中打出,然后根据错误信息去解决就好了;

本次我遇到的错误是:

centos7 中python2 版本和python3版本共存,即使pip3 install 的uwsgi直接启动也会调用python2,如上图调用的版本信息;

解决思路,直接找到pip3安装的uwsgi,把这个启动文件软链导/usr/bin目录下,替换调调用2的启动软链文件即可,如果无法替换,可以改个名字,比如uwsgi3,以后启动uwsgi的时候以uwsgi3 --http :9090 -w rest.py这种形式启动即可;

有的报错会是模块内app启动写法不对,根据相关报错找到对应解决方法即可;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章