繁体   English   中英

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

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

在将应用程序部署到 Google AppEngine 后,我在从远程服务器启动应用程序时遇到了很多麻烦。 我查找了类似的问题并尝试应用建议的修复程序,但仍然没有成功 - 我不断收到 502 Bad Gateway 问题。 有人可以建议吗?

文件夹结构是这样的:

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

应用程序.yml

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

主文件

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

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"]
  • 删除 app.yaml 中的entrypoint
  • 更新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.

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