部署到Heroku FastApi应用程序时出错

q9rjltbz  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(88)

在尝试和错误部署我的应用程序与uvicorn我能够完成它,但是,我看到以下错误的Heroku控制台。这对我来说不是很具体。有人知道如何调试此问题以找到根本原因?先谢了

错误日志

2023-07-19T13:04:13.000000+00:00 app[api]: Build succeeded
2023-07-19T13:05:10.527046+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2023-07-19T13:05:10.546612+00:00 heroku[web.1]: Stopping process with SIGKILL
2023-07-19T13:05:10.700117+00:00 heroku[web.1]: Process exited with status 137
2023-07-19T13:05:10.730885+00:00 heroku[web.1]: State changed from starting to crashed
2023-07-19T13:05:10.735343+00:00 heroku[web.1]: State changed from crashed to starting
2023-07-19T13:05:12.788784+00:00 heroku[web.1]: Starting process with command `uvicorn main:app --workers 4`
2023-07-19T13:05:13.684304+00:00 app[web.1]: INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
2023-07-19T13:05:13.684375+00:00 app[web.1]: INFO:     Started parent process [2]
2023-07-19T13:05:15.430957+00:00 app[web.1]: INFO:     Started server process [8]
2023-07-19T13:05:15.431032+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T13:05:15.431299+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T13:05:15.432258+00:00 app[web.1]: INFO:     Started server process [11]
2023-07-19T13:05:15.432325+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T13:05:15.432554+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T13:05:15.433642+00:00 app[web.1]: INFO:     Started server process [9]
2023-07-19T13:05:15.433721+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T13:05:15.433933+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T13:05:15.434971+00:00 app[web.1]: INFO:     Started server process [10]
2023-07-19T13:05:15.435040+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T13:05:15.435208+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T13:05:31.998450+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=desolate-springs-06739-298cdafdc988.herokuapp.com request_id=231191dd-7ab2-4716-88fb-6db19dc16f8d fwd="161.10.88.158" dyno= connect= service= status=503 bytes= protocol=https
2023-07-19T13:05:56.472474+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/docs" host=desolate-springs-06739-298cdafdc988.herokuapp.com request_id=c992f2b3-e4f9-442b-951a-ecc0a5ae19b0 fwd="161.10.88.158" dyno= connect= service= status=503 bytes= protocol=https
2023-07-19T13:06:13.120247+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2023-07-19T13:06:13.138141+00:00 heroku[web.1]: Stopping process with SIGKILL
2023-07-19T13:06:13.317055+00:00 heroku[web.1]: Process exited with status 137
2023-07-19T13:06:13.347697+00:00 heroku[web.1]: State changed from starting to crashed

字符串

错误日志- With --host 0.0.0.0

023-07-19T15:18:02.797373+00:00 heroku[web.1]: Starting process with command `uvicorn main:app --workers 4 --host 0.0.0.0`
2023-07-19T15:18:03.782322+00:00 app[web.1]: INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2023-07-19T15:18:03.782357+00:00 app[web.1]: INFO:     Started parent process [2]
2023-07-19T15:18:06.000000+00:00 app[api]: Build succeeded
2023-07-19T15:18:08.970870+00:00 app[web.1]: INFO:     Started server process [11]
2023-07-19T15:18:08.970918+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:18:08.971166+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:18:08.971859+00:00 app[web.1]: INFO:     Started server process [9]
2023-07-19T15:18:08.971910+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:18:08.972093+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:18:08.973391+00:00 app[web.1]: INFO:     Started server process [8]
2023-07-19T15:18:08.973449+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:18:08.973669+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:18:08.974498+00:00 app[web.1]: INFO:     Started server process [10]
2023-07-19T15:18:08.974587+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:18:08.974805+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:19:03.307790+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2023-07-19T15:19:03.330052+00:00 heroku[web.1]: Stopping process with SIGKILL
2023-07-19T15:19:03.539019+00:00 heroku[web.1]: Process exited with status 137
2023-07-19T15:19:03.573661+00:00 heroku[web.1]: State changed from starting to crashed
2023-07-19T15:19:03.578461+00:00 heroku[web.1]: State changed from crashed to starting
2023-07-19T15:19:05.867070+00:00 heroku[web.1]: Starting process with command `uvicorn main:app --workers 4 --host 0.0.0.0`
2023-07-19T15:19:06.995829+00:00 app[web.1]: INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2023-07-19T15:19:06.995908+00:00 app[web.1]: INFO:     Started parent process [2]
2023-07-19T15:19:13.837020+00:00 app[web.1]: INFO:     Started server process [10]
2023-07-19T15:19:13.837064+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:19:13.837277+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:19:13.942430+00:00 app[web.1]: INFO:     Started server process [8]
2023-07-19T15:19:13.942544+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:19:13.942872+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:19:13.957269+00:00 app[web.1]: INFO:     Started server process [9]
2023-07-19T15:19:13.959417+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:19:13.959679+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:19:13.990849+00:00 app[web.1]: INFO:     Started server process [11]
2023-07-19T15:19:13.992671+00:00 app[web.1]: INFO:     Waiting for application startup.
2023-07-19T15:19:13.992942+00:00 app[web.1]: INFO:     Application startup complete.
2023-07-19T15:19:49.450779+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=desolate-springs-06739-298cdafdc988.herokuapp.com request_id=6a572108-0558-4bbf-9c4d-ea5fcf9c7760 fwd="161.10.88.158" dyno= connect= service= status=503 bytes= protocol=https

Procfile

web: uvicorn main:app --workers 4

Main

app = FastAPI()

origins = [
    'http//:localhost:3000',
    'https://desolate-springs-06739-298cdafdc988.herokuapp.com'
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)


我试过检查进程文件,查看Heroku日志,但错误不是我特有的

qoefvg9y

qoefvg9y1#

有一种方法可以只使用uvicorn,但我最终使用了gunicorn web:gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app

相关问题