【问题标题】:/healthz route of an app deployed on Google App Engine returns 404部署在 Google App Engine 上的应用的 /healthz 路由返回 404
【发布时间】:2021-01-22 01:04:03
【问题描述】:

对部署在 Google App Engine 上的应用上的 /healthz 路由的 HTTP 请求似乎没有到达应用内的 /healthz 端点。
相反,提供404 页面,显然来自 GCP 基础架构。
我能否知道如何覆盖此行为并使这些请求到达我的应用?

谢谢。


更多背景知识:

我正在 Google App Engine 上部署 Streamlit 应用程序。
Streamlit Web UI 似乎定期向/healthz 端点发送请求,当这些请求失败时,Streamlit 应用程序停止工作并显示如下错误消息。

【问题讨论】:

    标签: google-app-engine google-cloud-platform google-app-engine-python app-engine-flexible streamlit


    【解决方案1】:

    我设法以一种相当讨厌的方式解决了 healthz 冲突。我还启用了session_affinity 来帮助进行 websocket 连接。

    这是我的app.yaml,下面将解释 healthz 修复:

    runtime: python
    env: flex
    # This is a horrible workaround to get streamlit working on app engine
    # https://discuss.streamlit.io/t/has-anyone-deployed-to-google-cloud-platform/931/20
    entrypoint: find ${VIRTUAL_ENV}/lib/python3.6/site-packages/streamlit -type f \( -iname \*.py -o -iname \*.js \) -print0 | xargs -0 sed -i 's/healthz/health-check/g' && streamlit run sim_v3.py --server.port $PORT --server.enableCORS=false
    
    runtime_config:
      python_version: 3
    
    manual_scaling:
      instances: 1
    
    network:
      session_affinity: true
    

    hack 发生在入口点命令中。我在 python virtualenv 依赖文件夹 site-packages 中找到所有文件,它们要么是 .py 要么是 .js,并将 healthz 替换为 health-check

    如果您打算支持已部署的 streamlit 应用程序,我建议您避免使用此解决方案。如果

    • google python运行时python版本变化
    • streamlit 进行更改以破坏此内联替换
    • google 决定更改其文件夹命名约定

    【讨论】:

      【解决方案2】:

      某些以z 结尾的网址路径(包括/healthz)保留供App Engine 使用,无法使用。

      【讨论】:

      • 有更多关于这个here的信息。
      猜你喜欢
      • 2019-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 2015-09-21
      • 2019-04-02
      • 2019-04-22
      相关资源
      最近更新 更多