【问题标题】:Django not running on herokuDjango没有在heroku上运行
【发布时间】:2012-02-14 00:58:17
【问题描述】:

按照“heroku/ceadar 上的 Django 入门”指南进行操作,最终解决了一些应用部署问题

Successfully installed django psycopg2
 Cleaning up...
 Discovering process types
 Procfile declares types -> (none)
 Compiled slug size is 8.0MB
 Launching... done, v4
 http://<watever>.herokuapp.com deployed to Heroku

并且指南说网络服务器应该启动。但是 heroku ps 没有显示任何进程,显然页面没有加载。

heroku 日志的尾部:

2012-01-19T10:28:29+00:00 heroku[web.1]: State changed from created to down
2012-01-19T10:28:30+00:00 heroku[web.1]: State changed from down to created
2012-01-19T10:28:32+00:00 heroku[slugc]: Slug compilation finished
2012-01-19T10:30:32+00:00 heroku[router]: Error H99 (Platform error) -> GET <watever>
.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=


(venv) C:\Python27\facebook\venv\myapp>heroku ps
Process  State  Command
-------  -----  -------

我应该明确启动网络服务器吗?我做错了吗?

【问题讨论】:

  • 你在你的 proc 文件中声明了一个 web 进程吗?例如: web: gunicorn_django -b 0.0.0.0:$PORT -w 9 -k gevent --max-requests 250 --preload settings

标签: django heroku


【解决方案1】:

我用于 django/heroku 实例的 Procfile 如下所示:

web: python hellodjango/manage.py runserver "0.0.0.0:$PORT" 

如前所述,如果您没有 Procfile 并且您使用的是默认网络服务器,它基本上会执行上述操作 - 但请尝试明确。您可以尝试从 heroku 控制台运行它,以查看它得到了什么(如果有)错误:

heroku run python hellodjango/manage.py runserver

【讨论】:

  • 不需要 Procfile。 Heroku 自动检测 django 应用程序为默认开发服务器启动它。
  • 正如我所说...如果您没有 Procfile 并且您使用的是默认 Web 服务器,它基本上会执行上述操作。但既然你遇到了麻烦,我建议你明确地这样做。
  • 默认服务器是什么?使用它有什么问题吗?
  • @MikeVella 你不能在生产中使用它,因为它甚至不是多线程的。 This guy 说要使用女服务员。
【解决方案2】:

我只是遇到了同样的问题,虽然我不知道是不是出于同样的原因。

在执行教程中的这个命令时:

django-admin.py startproject hellodjango .

我将应用程序的名称更改为其他名称(当然不仅仅是在此命令中),但我省略了“。”在末尾。这导致脚本在同名目录中创建一个应用程序,而不是在我所在的目录中,这导致 Heroku 的服务器端脚本无法将该应用程序检测为 Django 应用程序。

【讨论】:

    【解决方案3】:

    我也遇到了这个问题。通过运行确保您的 Procfile 看起来正确...

    $heroku run bash
    

    打开一个可以访问heroku的终端。然后……

    $cat Procfile
    

    这将显示您的 Procfile 中的实际内容。由于某种原因,我的第一行(在我的本地文件中)没有被读取。然后,我在文件中附加了一个“}”。我在 Mac 上的 TextEdit 中创建文件 - 应该使用 SublimeText 或其他文本编辑器。你也可以调用

    $echo "web: gunicorn hello:app" >> Procfile
    

    或者你想让你的 Procfile 说什么。这会将您的 Procfile 更改为您回显的任何内容。

    【讨论】:

    • 此更改 Procfile 但应用程序默认从不适用此更改的主分支部署。运行:heroku logs,可以找到Procfile config used。
    【解决方案4】:

    我已经在 Heroku 上与 Django 斗争了一段时间,并决定组装一个非常固执但功能强大的引导程序。我希望它可以帮助沿途的其他人:https://github.com/callmephilip/django-heroku-bootstrap

    【讨论】:

      【解决方案5】:

      关键在这里:

      Procfile declares types -> (none)
      

      Heroku 不知道如何运行您的应用程序。我假设python hellodjango/manage.py runserver 在本地为您工作?如果是这样,Heroku 应该可以接手。

      还要检查您在 repo 根目录中有一个 requirements.txt,在您的项目子目录之一中有一个 settings.py

      【讨论】:

      • runserver 在本地运行良好。并且 requirements.txt 和 settings.py 也存在。 ProcFile 位于 repo 根目录中,并且具有以下行: web: python madfb/manage.py runserver
      • 我第一次推送到 heroku 时,我没有 Procfile 并且它用词很好。我在安装gunicorn 后添加了Procfile。另外,请记住,雪松仍处于测试阶段
      • Cedar 在技术上是测试版,但远不是它不稳定的状态。如果您有“标准”设置,例如 Rails 或 Flask,则不需要 Procfile,Play!等
      • 我提出了一张票,heroku 回复了。看起来 django 应用程序目录没有签入,即使 GIT 说更改已被推送。我也给他们发了签到日志。现在我从头开始做了整个事情,使用了预编译的 psycog2 并且它可以工作。不需要 Procfile。 Heroku 自动检测 django 应用程序启动它。
      猜你喜欢
      • 2021-03-31
      • 2012-06-05
      • 2012-04-25
      • 2014-01-21
      • 1970-01-01
      • 2021-05-20
      • 2013-09-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多