问题描述
部署 streamlit 应用失败,日志信息如下:
[manager] Processed dependencies!
[manager] The service has encountered an error while checking the health of the Streamlit app: Get "http://localhost:8501/healthz": dial tcp 127.0.0.1:8501: connect: connection refused
[manager] Streamlit server consistently failed status checks
[manager] Please fix the errors, push an update to the git repo, or reboot the app.
解决方案
从日志信息中我们根本看不到任何有用的信息,也不知道为啥报错。从社区中搜索答案,发现有个网友分享了这样一个解决方案:
他说时把配置文件中的 headless
参数设置为 true
,按照这个方案我确实解决了错误。
这就要解释一下 headless 参数的作用了。官方给出的解释如下:
# If false, will attempt to open a browser window on start.
# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) we are running in the Streamlit Atom plugin.
如果为 false
,将尝试在启动时打开浏览器窗口。默认 false
,以下两种情况需要设置为 true
:
- (1)我们使用的是未设置 Display 的 Linux 机器
- (2)我们正在 Streamlight Atom 插件中运行。
部署一个 web 应用是在 Linux 主机上进行的,符合第一种情况,所以需要设置为 true
。
https://discuss.streamlit.io/t/manager-streamlit-server-consistently-failed-status-checks/11737/11