问题描述
在Google App Engine上部署的应用程序上对/healthz
路由的HTTP请求似乎未到达该应用程序内的/healthz
端点。
相反,显然是从GCP基础结构提供了404
页。
我可以知道如何覆盖此行为并使这些请求到达我的应用程序吗?
谢谢。
更多背景信息:
我正在Google App Engine上部署Streamlit应用。
Streamlit Web UI似乎正在定期向/healthz
端点发送请求,当这些请求失败时,Streamlit应用程序停止工作并显示如下错误消息。
解决方法
某些以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决定更改其文件夹命名约定