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

问题描述

在Google App Engine上部署的应用程序上对/healthz路由的HTTP请求似乎未到达该应用程序内的/healthz端点。
相反,显然是从GCP基础结构提供了404页。
我可以知道如何覆盖此行为并使这些请求到达我的应用程序吗?

谢谢。

enter image description here


更多背景信息:

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

enter image description here

解决方法

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

,

我设法以一种非常讨厌的方式解决了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

hacking发生在entrypoint命令中。我在python virtualenv依赖项文件夹site-packages中找到了所有.py.js的文件,并将healthz替换为health-check

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

  • 在Google python运行时中python版本的更改
  • streamlit进行的更改将中断此内联替换
  • google决定更改其文件夹命名约定