第一次使用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
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
$ 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'
Run Code Online (Sandbox Code Playgroud)
我一定要错过一些东西。
我已经requirements.txt在我的根目录中添加了一个。看起来像这样:
.git
.idea
projectapp
projectname
rango
db.sqlite3
manage.py
populate_rango.py
requirements.txt
Run Code Online (Sandbox Code Playgroud)
小智 9
使用部署时Docker,请确保将应用程序的堆栈设置为container,如文档中所示:
heroku stack:set container
Run Code Online (Sandbox Code Playgroud)
实际上heroku所做的是,它试图通过查看项目中的文件来确定您正在部署的项目,例如,如果您的项目有package.json文件,则它理解为nodejs项目,如果您的项目有requirements.txt文件,则它理解为python项目等等,请参阅此文档以了解您可以在 heroku 服务器上运行哪些语言
如您所知,在计算机节点运行时中运行特定项目(例如 nodejs 项目)必须安装在该计算机中,否则您无法在计算机中使用 nodejs 应用程序,heroku 是做什么的,它将您的每个应用程序运行在不同的容器中,这意味着在一个容器中只有一个应用程序正在运行,当然该容器已经安装了 nodejs,所以如果一个容器只运行一个应用程序,那么在容器中安装所有其他运行时是没有意义的,所以在我的情况下容器只有一个运行时节点。他们当然有其他类型的容器,例如 python 的一种类型,并且该容器已经安装了 python 运行时(特定版本),因此如果我的应用程序安装在 python 容器中,它将无法工作,因为我的应用程序在 nodejs 中。
为了将来参考,必须确保将带有代码的分支推送到heroku master。
如果您是从master分支分支出来的,并且所有代码都位于(例如)上,develop则将其推送到heroku主服务器上。
所以代替:
git push heroku master
Run Code Online (Sandbox Code Playgroud)
您将执行以下操作:
git push heroku develop:master
Run Code Online (Sandbox Code Playgroud)
这个问题有关于如何将不同的本地Git分支推送到Heroku / master的重要细节
您需要创建一个 runtime.txt 文件。在命令行上,在您的 requirements.txt 文件所在的文件夹中,输入echo "python-3.5.1" > runtime.txt. 当然,请确保将 3.5.1 与您使用的任何版本的 Python 切换。
Date Modified我不记得我是如何解决这个问题的,但是在发布这个问题后查看我的文件中的内容,我创建了两个文件:
runtime.txt(感谢rurp)其中包含:
python-3.5.2
Run Code Online (Sandbox Code Playgroud)
Procfile其中包含:
web: gunicorn projectname.wsgi --log-file -
Run Code Online (Sandbox Code Playgroud)
这是一个 Django 项目,projectname.wsgi导致wsgi.py位于
projectname/wsgi.py
这包含:
import os
import signal
import sys
import traceback
import time
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projectname.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16833 次 |
| 最近记录: |