Python Flask应用程序上的AWS Beanstalk错误504超时

时间:2018-11-21 19:10:00

标签: python amazon-web-services flask mod-wsgi amazon-elastic-beanstalk

我正在尝试在AWS Bean茎上部署Python Flask应用程序。我在python上有不错的经验,但是对部署来说是全新的。我收到一个错误消息,提示“ url 花费很长时间才能响应HTTP 504”。我的环境运行状况很好,并且所有对该实例的部署都未指示任何错误,但是我似乎遇到了504问题

错误看起来像这样:

Error 504

错误日志如下所示: Error Log

访问日志: Access Logs

这是我的代码:

from flask import Flask, request
  from flask_restful import Resource, Api

  import firebase_admin

  # For connecting to firestore database and authentication
from firebase_admin import credentials, firestore

 # For Cross-Origin Http requests
 from flask_cors import CORS, cross_origin

 # For Data base Connectivity
 from firebase_admin import db

 from flask import jsonify

  application = app = Flask(__name__)
  api = Api(app)


 CORS(app)

 class Firebase_Data(Resource):

     def get(self):

         return self._getData()

        def _getData(self):

         # Setting up credentials to connect
    cred = credentials.Certificate(****)

    # Setting up secure connection to firestore Real time database

        Kokomo_app = firebase_admin.initialize_app(cred, {
        'projectId' : '****'
       })


      # Connecting to the firestore client
    db_ref = firestore.client()

      # Referring to a section of the data
    ref_inc = db_ref.collection(****)

      # Fetching all the records under that particular section and converting 
       them to list of dictionaries
    docs = list( ref_inc.get() )



     lat_long = []

     for doc in docs:

        data = doc.to_dict()

        lat_long.append(

              { 'Latitude:' : data['latitude'], 'Longitude' : 
              data['longitude'] } )


       return lat_long


    api.add_resource(Firebase_Data, '/Firebase_Data') # Route_1

   if __name__ == '__main__':
      app.run()   

我的需求文件:

aniso8601==4.0.1

CacheControl==0.12.5

cachetools==3.0.0

certifi==2018.10.15

chardet==3.0.4

Click==7.0

firebase-admin==2.13.0

Flask==1.0.2

Flask-Cors==3.0.7

Flask-RESTful==0.3.6

google-api-core==1.5.2

google-auth==1.6.1

google-cloud-core==0.28.1

google-cloud-firestore==0.30.0

google-cloud-storage==1.13.0

google-resumable-media==0.3.1

googleapis-common-protos==1.5.5

grpcio==1.16.1

idna==2.7

itsdangerous==1.1.0

Jinja2==2.10

MarkupSafe==1.1.0

msgpack==0.5.6

protobuf==3.6.1

pyasn1==0.4.4

pyasn1-modules==0.2.2

pytz==2018.7

requests==2.20.1

rsa==4.0

six==1.11.0

urllib3==1.24.1

Werkzeug==0.14.1

我已经检查了日志,需求文件中的每个依赖项程序包似乎都已正确安装,没有任何问题,我正在使用apache库,还安装了最新的mod_wsgi程序包。...我关注了一些AWS资源并增加了负载均衡器超时,但无法解决问题

我已经看到许多与之相关的Stack溢出问题,但似乎没有找到完整或具体的答案。尽管如此,我创建这个问题的原因是因为我几乎没有部署尝试在我的免费套餐中,所以我想让他们计数。非常感谢您的时间和努力。

注意:请忽略此代码中的缩进。我对间距进行了严重操纵以使其适合代码块。

谢谢

0 个答案:

没有答案