应用程序部署错误任何人都可以帮我修复它
[Sat Apr 09 18:27:29.953008 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] mod_wsgi(pid = 3230) :目标WSGI脚本'/var/www/FlaskApps/FlaskApps.wsgi'无法作为Python模块加载。应用程序部署错误任何人都可以帮我修复它
[:09年4月18日18:27:29.953045 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] mod_wsgi(pid = 3230):处理WSGI脚本'/ var/WWW/FlaskApps/FlaskApps.wsgi”。
[周六18年4月9日:27:29.953065 2016年] [:错误] [PID 3230:TID 140635784853248] [客户103.14.196.22:53950]回溯(最近通话最后一个):
[星期六年4月9 18:27:29.953079 2016] [:错误] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950]文件“/var/www/FlaskApps/FlaskApps.wsgi”,line 8,in
[Sat Apr 09 18:27:29.953126 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] from run import app as application
[Sat Apr 09 18:27:29.953136 2016] :错误] [pid 3230:tid 140635784853248] [clie nt 103.14.196.22:53950]文件“/var/www/FlaskApps/PlagiarismDefenderApp/run.py”,第28行,在
[Sat Apr 09 18:27:29.953165 2016] [:error] [pid 3230: TID 140635784853248] [客户端103.14.196.22:53950]应用=前夕()
[星期六18年4月9日:27:29.953173 2016] [:错误] [3230 PID:TID 140635784853248] [客户端103.14.196.22:53950]文件 “/usr/local/lib/python2.7/dist-packages/eve/flaskapp.py”,线139,在初始化
[星期六18年4月9日:27:29.953371 2016] [:错误] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] self.validate_domain_struct()
[Sat Apr 09 18:27:29.953382 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] File“/usr/local/lib/python2.7/dist-packages/ eve/flaskapp.py“,第252行,in validate_domain_struct
[Sat Apr 09 18:27:29.953395 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] raise ConfigException(' DOMAIN dictionary missing or wrong。')
[Sat Apr 09 18:27:29.953408 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] ConfigException:DOMAIN字典丢失或错误。
home.py文件
# -*- coding: utf-8 -*-
import os
from eve import Eve
if 'PORT' in os.environ:
port = int(os.environ.get('PORT'))
host = '0.0.0.0'
else:
port = 5000
host = '127.0.0.1'
app = Eve()
if __name__ == '__main__':
app.run(host=host, port=port)
settins.py文件
import os
MONGO_HOST = os.environ.get('MONGO_HOST', 'localhost')
MONGO_PORT = os.environ.get('MONGO_PORT', 27017)
MONGO_USERNAME = os.environ.get('MONGO_USERNAME', 'user')
MONGO_PASSWORD = os.environ.get('MONGO_PASSWORD', 'user')
MONGO_DBNAME = os.environ.get('MONGO_DBNAME', 'evedemo')
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
ITEM_METHODS = ['GET', 'PATCH', 'DELETE']
CACHE_CONTROL = 'max-age=20'
CACHE_EXPIRES = 20
people = {
# 'title' tag used in item links.
'item_title': 'person',
'additional_lookup': {
'url': 'regex("[\w]+")',
'field': 'lastname'
},
'schema': {
'firstname': {
'type': 'string',
'minlength': 1,
'maxlength': 10,
},
'lastname': {
'type': 'string',
'minlength': 1,
'maxlength': 15,
'required': True,
},
'role': {
'type': 'list',
'allowed': ["author", "contributor", "copy"],
},
# An embedded 'strongly-typed' dictionary.
'location': {
'type': 'dict',
'schema': {
'address': {'type': 'string'},
'city': {'type': 'string'}
},
},
'born': {
'type': 'datetime',
},
}
}
works = {
'cache_control': 'max-age=10,must-revalidate',
'cache_expires': 10,
'schema': {
'title': {
'type': 'string',
'required': True,
},
'description': {
'type': 'string',
},
'owner': {
'type': 'objectid',
'required': True,
'data_relation': {
'resource': 'people',
'embeddable': True
},
},
}
}
DOMAIN = {
'people': people,
'works': works,
}
/var/www/FlaskApps/FlaskApps.wsgi
#! /usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApps/PlagiarismDefenderApp/")
# home points to the home.py file
from home import app as application
application.secret_key = "somesecretsessionkey"
检查settings
路径前夕应用正在使用。检查它是否与你的settings.py
相符。如果您将应用指向错误的settings.py路径,则可能会引发此错误。
此外,我想这是一个错字,但你写了settins.py
。如果这是正确的,那就是你的问题。您需要在应用程序的相同文件夹上有settings.py
,或者您需要将settings
路径传递给应用程序。
有关文件配置的详细说明,请参阅Eve文档here。
该错误ConfigException: DOMAIN dictionary missing or wrong.
是非常误导。 当我遇到这样的错误,我调试flaskapp.py 0123,,通过逐行逐行。这有总是帮我找到了根本原因。
您使用的是哪个版本的前夕? https://github.com/nicolaiarocci/eve/issues/823表示它在前夕0.6+已修复
这是告诉你,你的DOMAINS字典有问题。查阅文档,了解夏娃的期望。 – snakecharmerb
您的'DOMAIN'字典是可以的,我已经在我的环境中使用gevent WSGI服务器进行了测试。我曾经看到过这个问题,我会尽力记住它是什么。 – gcw