第一次使用 Heroku。试图推动。我已经运行命令:
heroku create --buildpack heroku/python
它显示
$ heroku create --buildpack heroku/python
Creating app... done, glacial-reef-7599
Setting buildpack to heroku/python... done
https://glacial-reef-7599.herokuapp.com/ | https://git.heroku.com/glacial-reef-7599.git
堆栈跟踪:
$ git push heroku master
Counting objects: 129, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (124/124), done.
Writing objects: 100% (129/129), 69.06 KiB | 0 bytes/s, done.
Total 129 (delta 22), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to pure-badlands-9125.
remote:
To https://git.heroku.com/pure-badlands-9125.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pure-badlands-9125.git'
我一定错过了一些东西。
我添加了一个requirements.txt
到我的根目录。它看起来像这样:
.git
.idea
projectapp
projectname
rango
db.sqlite3
manage.py
populate_rango.py
requirements.txt
快速解决方案
- Goto Heroku 仪表板 (https://dashboard.heroku.com/ https://dashboard.heroku.com/)
-
进入应用程序/项目内部
- 点击设置
- 向下滚动一点单击添加构建包
-
选择您想要的构建包(就我而言,我选择了heroku/nodejs)。
TLDR;
实际上,heroku 所做的是,它尝试通过查看项目中的文件来识别您正在部署的项目,例如您的项目是否有package.json
文件它理解它是一个nodejs项目,如果你的项目有requirements.txt
文件它知道它是一个 python 项目等等,请参阅这个文件 https://devcenter.heroku.com/start查看您可以在 heroku 服务器上运行哪些语言
如您所知,要在计算机中运行特定项目(例如nodejs项目),必须在该计算机中安装node运行时,否则您无法在计算机中安装nodejs应用程序,heroku会在不同的容器中运行每个应用程序,这意味着在一个容器中,只有一个应用程序正在运行,当然该容器已经安装了nodejs,因此,如果一个容器只运行一个应用程序,那么在容器中安装所有其他运行时是没有意义的,因此在我的情况下,容器只有一个运行时节点。他们当然有其他类型的容器,例如 python 的一种类型,并且该容器已经安装了 python 运行时(特定版本),因此如果我的应用程序安装在 python 容器中,它将无法工作,因为我的应用程序位于 Nodejs 中。出于这个原因,我们需要在开始选择正确的容器类型时识别应用程序的类型,大多数情况下,heroku 会自动检测它,但如果未能检测到,您必须通过转到其仪表板设置或通过运行时文件来明确告知您的项目,您可能已经注意到,您只执行过一次。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)