在我的uwsgi配置中,我有以下选项:
[uwsgi]
chmod-socket = 777
socket = 127.0.0.1:9031
plugins = python
pythonpath = /adminserver/
callable = app
master = True
processes = 4
reload-mercy = 8
cpu-affinity = 1
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
no-orphans
vacuum
我的应用程序结构如下:
/adminserver
app.py
...
我的app.py
有以下代码:
app = Flask(__name__)
...
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5003, debug=True)
结果是,当我试图卷曲我的服务器时,我得到了以下错误:
Wed Sep 11 23:28:56 2013 - added /adminserver/ to pythonpath.
Wed Sep 11 23:28:56 2013 - *** no app loaded. going in full dynamic mode ***
Wed Sep 11 23:28:56 2013 - *** uWSGI is running in multiple interpreter mode ***
module
和callable
选项是做什么的?医生说:
模块,wsgi参数: string 加载一个WSGI模块作为应用程序。模块(sans .py)必须是不可输入的。在巴黎。 可以使用命令行的-w设置此选项。 可调用的参数:字符串默认值:应用程序 设置默认的WSGI可调用名称。
发布于 2013-09-12 04:09:49
模块
Python中的一个模块映射到磁盘上的文件--当您有如下目录时:
/some-dir
module1.py
module2.py
如果在当前工作目录为/some-dir
时启动python解释器,则可以导入每个模块:
some-dir$ python
>>> import module1, module2
# Module1 and Module2 are now imported
Python在sys.path
(以及其他一些东西, for more information)中搜索一个与您试图导入的名称匹配的文件。uwsgi在幕后使用Python的导入过程来加载包含WSGI应用程序的模块。
可赎回
WSGI (333和3333)指定WSGI应用程序is a callable that takes two arguments and returns an iterable that yields bytestrings
# simple_wsgi.py
# The simplest WSGI application
HELLO_WORLD = b"Hello world!\n"
def simple_app(environ, start_response):
"""Simplest possible application object"""
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [HELLO_WORLD]
uwsgi需要知道模块中映射到WSGI应用程序可调用的符号的名称,这样它就可以在环境中传递和start_response
可调用--本质上,它需要能够执行以下操作:
wsgi_app = getattr(simple_wsgi, 'simple_app')
TL;PC (太长;首选代码)
与uwsgi正在做的事情有一个简单的平行:
# Use `module` to know *what* to import
import simple_wsgi
# construct request environment from user input
# create a callable to pass for start_response
# and then ...
# use `callable` to know what to call
wsgi_app = getattr(simple_wsgi, 'simple_app')
# and then call it to respond to the user
response = wsgi_app(environ, start_response)
发布于 2014-05-03 15:11:57
对于有此问题的其他任何人,如果您确信您的配置是正确的,则应该检查您的uWSGI版本。
Ubuntu12.04LTS提供1.0.3。删除它并使用pip安装2.0.4解决了我的问题。
发布于 2018-05-11 06:48:26
首先,检查您的配置是否正确。
我的uwsgi.ini
配置:
[uwsgi]
chdir=/home/air/repo/Qiy
uid=nobody
gid=nobody
module=Qiy.wsgi:application
socket=/home/air/repo/Qiy/uwsgi.sock
master=true
workers=5
pidfile=/home/air/repo/Qiy/uwsgi.pid
vacuum=true
thunder-lock=true
enable-threads=true
harakiri=30
post-buffering=4096
daemonize=/home/air/repo/Qiy/uwsgi.log
然后使用uwsgi --ini uwsgi.ini
运行uwsgi。
如果不工作,您可以rm -rf
venv
目录,并重新初始化venv,然后重试我的步骤。
我重新启动了venv
解决了我的问题,似乎问题是当我pip3 install
一些requirements.txt
软件包,并升级pip,然后安装uwsgi
软件包。因此,我删除venv
,并重新初始化我的虚拟环境。
https://stackoverflow.com/questions/18753085
复制相似问题