【问题标题】:eve app deployment errors can anyone help me to fix iteve 应用程序部署错误谁能帮我修复它
【发布时间】:2016-07-30 23:45:03
【问题描述】:

[2016 年 4 月 9 日星期六 18:27:29.953008] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] mod_wsgi (pid=3230): Target WSGI script '/var/www/FlaskApps /FlaskApps.wsgi' 不能作为 Python 模块加载。

[2016 年 4 月 9 日星期六 18:27:29.953045] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] mod_wsgi (pid=3230): 处理 WSGI 脚本 '/var/www /FlaskApps/FlaskApps.wsgi'。

[Sat Apr 09 18:27:29.953065 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] Traceback(最近一次通话最后):

[2016 年 4 月 9 日星期六 18:27:29.953079] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] 文件“/var/www/FlaskApps/FlaskApps.wsgi”,第 8 行,在

[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] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] 文件“/var/www/FlaskApps/PlagiarismDefenderApp/run.py”,行28、在

[2016 年 4 月 9 日星期六 18:27:29.953165] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] app = Eve()

[2016 年 4 月 9 日星期六 18:27:29.953173] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] 文件“/usr/local/lib/python2.7/dist-packages/ eve/flaskapp.py”,第 139 行,在 init

[2016 年 4 月 9 日星期六 18:27:29.953371] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] self.validate_domain_struct()

[2016 年 4 月 9 日星期六 18:27:29.953382] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] 文件“/usr/local/lib/python2.7/dist-packages/ eve/flaskapp.py”,第 252 行,在 validate_domain_struct 中

[2016 年 4 月 9 日星期六 18:27:29.953395] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] raise ConfigException('DOMAIN dictionary missing or wrong.')

[2016 年 4 月 9 日星期六 18:27:29.953408] [: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"

【问题讨论】:

  • 你的 DOMAIN 字典没问题,我已经在我的环境中使用 gevent WSGI 服务器进行了测试。我曾经看到过这个问题,我会试着记住它是什么。

标签: python wsgi eve


【解决方案1】:

检查 Eve 应用正在使用的 settings 路径。检查它是否与您的settings.py 匹配。如果您将应用程序指向错误的 settings.py 路径,则会引发此错误。

另外,我想这是一个错字,但你写了settins.py。如果这是正确的,那就是你的问题。您需要在与应用程序相同的文件夹中有一个settings.py,或者您需要将settings 路径传递给应用程序。

有关文件配置的详细说明,请参阅 Eve 文档here

【讨论】:

    【解决方案2】:

    错误ConfigException: DOMAIN dictionary missing or wrong. 非常具有误导性。 当我遇到此类错误时,我会逐行调试flaskapp.py 中的validate_domain_struct。这总是帮助我找到了根本原因。

    你用的是哪个版本的eve? https://github.com/nicolaiarocci/eve/issues/823 说它是在 eve 0.6+ 中修复的

    【讨论】:

      猜你喜欢
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-13
      • 1970-01-01
      相关资源
      最近更新 更多