【发布时间】:2020-02-06 04:40:17
【问题描述】:
在将应用程序部署到 Google AppEngine 后,我从远程服务器启动应用程序时遇到了很多麻烦。我查找了类似的问题并尝试应用建议的修复程序,但仍然没有成功 - 我不断收到 502 Bad Gateway 问题。有人可以建议吗?
文件夹结构是这样的:
目录:cross_sell_dash/
app.yml
数据库.py
Dockerfile
gcp-sa-creds.json
main.py
要求.txt
app.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
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"]
【问题讨论】:
-
嘿,这在本地有效吗?它只在 GAE 上失败?您能否也发布您的 requirements.txt ?你能解释一下为什么你使用 python:3-onbuild 而不仅仅是 python3 吗?您的 VM 实例是否正常运行?当应用程序无法响应请求时,通常会发生错误网关。 (可能从未初始化或崩溃)让我知道。
标签: python google-app-engine debugging flask