简体   繁体   English

Google AppEngine:502 Bad Gateway 从部署 Flask 应用程序

[英]Google AppEngine: 502 Bad Gateway From Deploying Flask App

I'm experiencing so much trouble launch my application from the remote server after deploying it to Google AppEngine.在将应用程序部署到 Google AppEngine 后,我在从远程服务器启动应用程序时遇到了很多麻烦。 I've looked up similar questions and tried to apply the suggested fixes, but still no success - I keep getting that 502 Bad Gateway Issue.我查找了类似的问题并尝试应用建议的修复程序,但仍然没有成功 - 我不断收到 502 Bad Gateway 问题。 Could someone please advise?有人可以建议吗?

Folder structure is like this:文件夹结构是这样的:

directory: cross_sell_dash/目录:cross_sell_dash/
app.yml应用程序.yml
database.py数据库.py
Dockerfile Dockerfile
gcp-sa-creds.json gcp-sa-creds.json
main.py主文件
requirements.txt要求.txt

app.yml应用程序.yml

entrypoint: "gunicorn --bind:$PORT main:app"
env: flex
runtime: custom

main.py主文件

app = Flask(__name__)

@app.route("/call/<function_name>/search/", methods=["GET"])
def callFunction(function_name: str):
    user_id = request.args.get('user_id')
    savm_id = request.args.get('savm_id')
    business_sub_entity = request.args.get('business_sub_entity')
    user_comments = request.args.get('user_comments')
    user_approval = request.args.get('user_approval')
    functionToCall = getattr(Database(), function_name)
    return str(functionToCall(user_id, savm_id, business_sub_entity, user_comments, user_approval))

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080, debug=True)

Dockerfile Dockerfile

FROM python:3-onbuild

RUN mkdir /app
ADD . /app

WORKDIR /app

RUN pip3 --no-cache-dir install -r requirements.txt

EXPOSE 8080

ENTRYPOINT ["python3", "main.py"]
ENTRYPOINT ["gunicorn","--bind=0.0.0.0:8080","main:app"]
  • Remove the entrypoint in app.yaml删除 app.yaml 中的entrypoint
  • Update Dockerfile as follows更新Dockerfile如下
FROM python:3-onbuild

RUN mkdir /app
ADD . /app

WORKDIR /app

RUN pip3 --no-cache-dir install -r requirements.txt

EXPOSE 8080

ENTRYPOINT ["gunicorn", "--bind=0.0.0.0:8080", "main:app"]

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

相关问题 在 AWS EC2 上部署 Flask 应用程序时出现 502 Bad Gateway - 502 Bad Gateway when deploying Flask app on AWS EC2 Gunicorn + nginx 502 错误网关上的 Flask 应用程序 - Flask app on Gunicorn + nginx 502 Bad Gateway 部署 Flask 应用程序时,AWS ElasticBeanstalk 中出现 502 Bad Gateway 错误 - 502 Bad Gateway Error in AWS ElasticBeanstalk while deploying Flask Application Google Cloud App Engine:Flask 应用程序出现 502 Bad Gateway (nginx) 错误 - Google Cloud App Engine: 502 Bad Gateway (nginx) error with Flask App 无法在 Google App Engine 上部署 Flask 应用程序,收到错误“502 Bad Gateway” - Unable to deploy Flask App on Google App Engine getting an error “502 Bad Gateway” Nginx / Flask / Python应用程序,Nginx抛出502 Bad Gateway错误 - Nginx/Flask/Python App, Nginx throwing 502 Bad Gateway Error 错误:nginx和uwsgi上的烧瓶应用程序中的502错误网关 - error: 502 bad gateway in flask app on nginx and uwsgi 在 GCP 中浏览 Flask 应用时出现“502 Bad Gateway nginx”错误 - '502 Bad Gateway nginx' error for browsing Flask app in GCP Django 在 Google App Engine 上出现“502 Bad Gateway”错误 - Django gives “502 Bad Gateway” error on Google App Engine Nginx 502错误网关错误时带有gunicorn的烧瓶 - Flask with gunicorn on nginx 502 bad gateway error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM