错误 R10(启动超时)-> 在 Heroku 上构建 streamlit web 应用程序时,Web 进程无法在启动后 60 秒内绑定到 $PORT

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch when building a streamlit web app on Heroku

我在 Heroku 上构建 Web 应用程序时遇到了这个问题:

2020-10-24T03:56:57.857273+00:00 app[web.1]: You can now view your Streamlit app in your browser.
2020-10-24T03:56:57.857320+00:00 app[web.1]: 
2020-10-24T03:56:57.857675+00:00 app[web.1]: Network URL: http://172.17.131.6:8501
2020-10-24T03:56:57.857819+00:00 app[web.1]: External URL: http://34.202.9.122:8501
2020-10-24T03:56:57.857932+00:00 app[web.1]: 
2020-10-24T03:56:59.458188+00:00 app[web.1]: 2020-10-24 03:56:59.458 Generating new fontManager, this may take some time...
2020-10-24T03:57:41.000000+00:00 app[api]: Build succeeded

2020-10-24T03:57:52.127634+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-10-24T03:57:52.147741+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-10-24T03:57:52.252583+00:00 heroku[web.1]: Process exited with status 137
2020-10-24T03:57:52.301275+00:00 heroku[web.1]: State changed from starting to crashed
2020-10-24T03:57:53.705631+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=okc-thunder-rebounds.herokuapp.com request_id=a90bb347-f583-4bec-8a6c-37bfea93908e fwd="71.232.30.113" dyno= connect= service= status=503 bytes= protocol=https

我的 setup.sh 是这样的:

mkdir -p ~/.streamlit/
  
echo "\
[general]\n\
email = \"qemail@domain.com\"\n\
" > ~/.streamlit/credentials.toml

echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml

我的 Procfile 是这样的:

web: sh setup.sh && streamlit run rebound_app.py

哪里出错了?

应用程序必须通过 $PORT 环境变量绑定到 Heroku 提供的端口。这是每个 Web Dyno 的要求。

您需要将 $PORT 传递给 streamlit

echo PORT $PORT
streamlit run  --server.port $PORT rebound_app.py