Heroku Procfile 正常,dynos 已正确缩放,但我仍然收到错误消息 "No web processes running"

Heroku Procfile is OK and dynos are correctly scaled but I still get the error message "No web processes running"

我为我的 cs50 期末项目创建了一个 flask 应用程序。它已通过 Github 成功部署到 Heroku,但由于某种原因无法正常工作。

当 运行 在本地使用 flask run 时它工作正常。

My project folder is organized like this

Procfile 内容如下:

网络:gunicorn app:app

根据我猜是对的。

按照 heroku 的说明我 运行 heroku logs --tail --app [APP] 看看有什么问题

这是我收到的错误消息:

at=error code=H14 desc="No web processes running" method=GET path="/" host=joking.herokuapp.com request_id=029d94b3-938c-4623-8421-7246c2ba52dc fwd= “177.104.215.5”dyno=connect=service=status=503 bytes=protocol=https

为什么我在Procfile中明确定义了web进程运行?
此外,我在网上搜索了(例如看这些帖子:A, B and C) 并且人们通常通过 运行
heroku ps:scale web=1

来解决这个问题

我这样做了,但不幸的是它没有解决问题。这是消息 returns:

缩放测功机...完成,现在 运行 网页位于 1:Free

所以看来dynos缩放是可以的。

那可能是什么问题呢?我错过了什么吗?
我接受任何建议。也许我的代码有问题?或者文件和文件夹的组织方式?独角兽?

Here you can check out the github repository with all the code(请不要嫌弃README.md文件,我还是会好好写的)

我在我的 heroku 上部署了您的应用程序。没有像 no web proccess running 这样的错误。 您可以通过 heroku 的概览选项卡查看是否附加了任何 dyno。

gunicorn worker 仍然无法启动。原因是您没有在 app.run()

中定义主机和端口参数

应该是这样的:

if __name__ == "__main__":
    port = int(os.environ.get("PORT", 5000))
    app.run(host="0.0.0.0",port=port)

我注意到的第二件事是您正在为数据库使用 sqlite(db 文件)。

heroku doesn't support sqlite worker restart overtime and all the file come in the state on which they were deployed any uploaded file or updated file will be lost. here is the resources.

Heroku 有postgresql 数据库可以使用,但是你需要使用psgcopg2(我不太清楚)或者使用支持各种数据库的flask-sqlalchemy。 您可以找到几个 articles 和视频来使用 postgresql 部署应用程序。

以同样的方式,您将无法在 heroku 中保存 profile_pics 个用户。 您可以将 firebase 存储系统与 pyrebase package for uploading files to server. docs

一起使用

您可以访问已部署的应用程序here