当尝试运行我的flask应用程序时,我得到错误:
uwsgi no module named site
我创建了一个这样的配置文件:
[uwsgi]
socket = 127.0.0.1:8000
processes = 4
virtualenv = /var/www/test/venv
chdir = /var/www/test
module = run
callable = manager
logto = var/www/uwsgi.log
我的run.py的位置是/var/www/test/run.py,代码如下:
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager
from app import app, db
if __name__ == "__main__":
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.run()
有谁能帮我理解一下我哪里做错了吗?我在运行一个全系统的UWSGI。
编辑
我使用pip安装了uwsgi和virtualenv,我有以下版本:
我的全系统python版本(以及我的venv中的版本)是:Python 2.7.3
您不希望同时使用app.run()(或manager.run())和uwsgi,因为:
因此,您只需要正确设置uwsgi,这样的设置就可以:
app-name = test
pidfile = /run/uwsgi/%(app-name)/pid
socket = /run/uwsgi/%(app-name)/socket
logto = /var/log/uwsgi/%(app-name).log
log-date = true
processes = 4
plugins = http,python
base = /srv/www/%(app-name)
home = %(base)/venv # http://uwsgi-docs.readthedocs.org/en/latest/Options.html#home-virtualenv-venv-pyhome
pythonpath = %(base)/venv # http://uwsgi-docs.readthedocs.org/en/latest/Options.html#pythonpath-python-path-pp
module = app
callable = app
chdir = %(base)