0

我对部署 python Web 应用程序相对较新,但我试图将我的 H2O wave 应用程序部署到 Heroku,但一直遇到问题,我在文档中找不到太多帮助。

如果我使用命令(在 SDK for wave 中)启动服务器,一切都在本地正常工作:

$ ./waved
2021/01/22 10:26:38 # 
2021/01/22 10:26:38 # ┌─────────────────────────┐
2021/01/22 10:26:38 # │  ┌    ┌ ┌──┐ ┌  ┌ ┌──┐  │ H2O Wave
2021/01/22 10:26:38 # │  │ ┌──┘ │──│ │  │ └┐    │ 0.11.0 20210118061246
2021/01/22 10:26:38 # │  └─┘    ┘  ┘ └──┘  └─┘  │ © 2020 H2O.ai, Inc.
2021/01/22 10:26:38 # └─────────────────────────┘
2021/01/22 10:26:38 # 
2021/01/22 10:26:38 # {"address":":10101","t":"listen","webroot":"/Users/kenjohnson/Documents/TTT/H2O Wave/wave/www"}
2021/01/22 10:26:39 # {"addr":"127.0.0.1:64065","route":"/tennis-pred","t":"ui_add"}
2021/01/22 10:46:04 # {"host":"http://127.0.0.1:8000","route":"/counter","t":"app_add"}

然后在项目的根目录下运行:

uvicorn tennis_pred_app:main

对于部署,除了我的 wave python 文件之外,我只有 arequirements.txt和 a Procfile

web: uvicorn tennis_pred_app:main --host 0.0.0.0 --port 10101

这就是我的 foo (tennis_pred_app.py) 的样子(简化):

from h2o_wave import Q, main, app, ui

@app("/tennis-pred")
async def serve(q: Q):
    show_form(q)
    await q.page.save()

我目前遇到的错误是:

2021-01-22T00:28:41.000000+00:00 app[api]: Build started by user x
2021-01-22T00:31:07.040695+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-22T00:31:06.879674+00:00 app[api]: Deploy 1dc65130 by user x
2021-01-22T00:31:06.879674+00:00 app[api]: Release v23 created by user x
2021-01-22T00:31:26.580199+00:00 heroku[web.1]: Starting process with command `uvicorn tennis_pred_app:main --host 0.0.0.0 --port 20819`
2021-01-22T00:31:30.299421+00:00 app[web.1]: INFO:     Uvicorn running on http://0.0.0.0:20819 (Press CTRL+C to quit)
2021-01-22T00:31:30.299892+00:00 app[web.1]: INFO:     Started parent process [4]
2021-01-22T00:31:46.000000+00:00 app[api]: Build succeeded
2021-01-22T00:32:27.041954+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-01-22T00:32:27.093099+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-01-22T00:32:27.199933+00:00 heroku[web.1]: Process exited with status 137
2021-01-22T00:32:27.242769+00:00 heroku[web.1]: State changed from starting to crashed
4

1 回答 1

2

你不能在 Heroku 上选择你的端口。相反, Heroku 通过环境变量为您分配一个端口PORT

改变你Procfile

web: uvicorn foo:main --host 0.0.0.0 --port 10101

web: uvicorn foo:main --host 0.0.0.0 --port $PORT
于 2021-01-21T22:39:38.303 回答