部署在 Google App Engine 上的应用程序的 /healthz 路由返回 404

use*_*505 5 google-app-engine google-cloud-platform google-app-engine-python app-engine-flexible streamlit

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

谢谢你。

在此处输入图片说明.

多一点背景:

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

在此处输入图片说明

Dus*_*ram 6

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


小智 5

我设法以一种相当讨厌的方式解决了 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
Run Code Online (Sandbox Code Playgroud)

入侵发生在入口点命令中。我发现在蟒蛇的virtualenv依赖性文件夹中的所有文件,site-packages即要么.py或者.js和更换healthzhealth-check

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

  • google python 运行时的python版本变化
  • streamlit 做一个改变,这会破坏这个内联替换
  • 谷歌决定改变他们的文件夹命名约定