在Heroku上部署Django应用

3
我一直在遵循 Heroku Django 教程,网址是 http://devcenter.heroku.com/articles/django,但我总是遇到以下问题。当我运行 heroku open 并访问我的应用程序网站时,总是出现“应用程序错误”。当我查看日志时,看到以下几行:
2011-10-11T04:55:35+00:00 heroku[web.1]: Starting process with command `python hellodjango/manage.py runserver`
2011-10-11T04:55:35+00:00 app[web.1]: python: can't open file 'hellodjango/manage.py': [Errno 2] No such file or directory

我的ProcFile只包含web: python hellodjango/manage.py runserver

最后,当我在命令行使用foreman start时,我的Django应用程序在本地运行良好。

有什么想法吗?谢谢。

1个回答

1
您的 "hellodjango" 目录是否已添加、提交到Git并推送到Heroku?您可以通过以下方式确保此操作:
git status

此外,您可以使用以下命令探索一个隔离的 dyno 实例,其中包含您的应用程序代码和配置变量:

heroku run bash

这样可以确保文件存在,如果您能够在Procfile中运行相同的命令,则应该看到相同的结果,以帮助进行故障排除。


最终,我通过将 ProcFile 更改为 "worker: python hellodjango/manage.py runserver" 来使其工作。我想我并不真正清楚在 ProcFile 中 web 和 worker 应该放什么。 - randomletters
@randomletters 不要使用"worker: python hellodjango/manage.py runserver"这种方式。你正在使用开发服务器运行项目,这会导致长时间运行时出现大量缓存积累。更不用说,在生产环境中几个小时后很可能会崩溃。让Heroku为您处理部署!尝试使用Fabric推送/部署您的代码库,并像CraigKerstiens建议的那样使用"heroku run"。 - Mykel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接