简体   繁体   English

在AWS Lambda上部署WSGi应用程序

[英]Deploying WSGi app on AWS Lambda

I am trying to deploy WSGi based app that's built using Python, Flask on AWS Lambda. 我正在尝试在AWS Lambda上部署使用Python Flask构建的基于WSGi的应用程序。

But, it seems that the round trip of the request is going but when the request is being returned the werkzeug module is not able to call LambdaContext: Not a callable object. 但是,似乎请求的往返过程正在进行,但是当返回请求时,werkzeug模块无法调用LambdaContext:不是可调用对象。

'LambdaContext' object is not callable: TypeError Traceback (most recent call last): File "/home/ubuntu/venv/local/lib/python2.7/site-packages/flask/app.py", line 1997, in call File "/home/ubuntu/venv/local/lib/python2.7/site-packages/flask/app.py", line 1989, in wsgi_app File "/tmp/pip-install-Xytrxp/Werkzeug/werkzeug/wrappers.py", line 1277, in call TypeError: 'LambdaContext' object is not callable “ LambdaContext”对象不可调用:TypeError追溯(最近一次调用最近):文件“ /home/ubuntu/venv/local/lib/python2.7/site-packages/flask/app.py”,行1997,正在调用在wsgi_app中的第1989行,文件“ /home/ubuntu/venv/local/lib/python2.7/site-packages/flask/app.py”,文件“ / tmp / pip-install-Xytrxp / Werkzeug / werkzeug / wrappers”。 py”,第1277行,在调用 TypeError中:“ LambdaContext”对象不可调用

I am trying to use serverless to deploy but my problem is that when i build a deployment package using serverless it's going to go beyond 250 MB which is the limit of AWS Lambda 我正在尝试使用无服务器进行部署,但是我的问题是,当我使用无服务器构建部署程序包时,它将超出250 MB,这是AWS Lambda的限制

I have built the package using Zappa by removing some of the unnecessary files in python packages and the size of that is 248 MB. 我通过删除python软件包中的一些不必要的文件,使用Zappa构建了该软件包,其大小为248 MB。 I am able to use that to deploy but using serverless deploy is throwing issues. 我能够使用它来进行部署,但是使用无服务器部署会引发问题。

So, is any one aware of what actually serverless does? 那么,有没有人知道无服务器的实际作用呢? Can we include serve.py and wsgi.py files in the AWS Lambda deployment package? 我们可以在AWS Lambda部署程序包中包含serve.py和wsgi.py文件吗?

If yes, what are more changes needed to be able to just add these python files to deployment package to make the application wrapped on serverless. 如果是的话,还需要进行哪些更改才能将这些python文件添加到部署程序包中,以使应用程序包装在无服务器上。

I was able to handle this by using serverless-wsgi. 我可以通过使用serverless-wsgi来解决此问题。 We just need to include wsgi.py and .wsgi_app files and need to put wsgi.handler as the Lambda Function Handler 我们只需要包含wsgi.py和.wsgi_app文件,并需要将wsgi.handler用作Lambda函数处理程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM