繁体   English   中英

Heroku 中没有运行 Django 的 Web 进程

[英]No web processes running Django in heroku

我试图在heroku中部署我的应用程序,但是当我最终尝试在heroku中运行我的应用程序时,我在浏览器中看到了这个:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

当我看到我的日志时,我得到下一个:

2013-08-31T19:53:30.672416+00:00 heroku[api]: Enable Logplex by user@example.com
2013-08-31T19:53:30.700218+00:00 heroku[api]: Release v2 created by user@example.com
2013-08-31T19:58:41+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:04:12.967456+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:04:13.161016+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:13:46+00:00 heroku[slug-compiler]: Slug compilation timed out: 904.285527871 seconds.
2013-08-31T20:22:52.646361+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:22:55.043424+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:26:14+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:38:41+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:41:22+00:00 heroku[slug-compiler]: Slug compilation timed out: 908.241350492 seconds.
2013-08-31T20:49:24.238496+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:49:24.644910+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=502 bytes=
2013-08-31T20:53:47+00:00 heroku[slug-compiler]: Slug compilation timed out: 907.148099965 seconds.
2013-08-31T20:56:59+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-31T20:58:50.641624+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_AQUA resource by user@example.com
2013-08-31T20:58:50.658435+00:00 heroku[api]: Release v3 created by user@example.com
2013-08-31T20:58:50.742803+00:00 heroku[api]: Add DATABASE_URL config by user@example.com
2013-08-31T20:58:50.782484+00:00 heroku[api]: Release v4 created by user@example.com
2013-08-31T20:58:50.840509+00:00 heroku[api]: Deploy 78dba6c by user@example.com
2013-08-31T20:58:50.852187+00:00 heroku[api]: Release v5 created by user@example.com
2013-08-31T20:58:54+00:00 heroku[slug-compiler]: Slug compilation finished
2013-08-31T21:00:25.085053+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:00:24.751074+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:01:03.272614+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:01:03.815558+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:02:10.279054+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:03:25.381362+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:03:25.709121+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
2013-08-31T21:03:45.285962+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/favicon.ico host=cristowip.herokuapp.com fwd="189.137.81.39" dyno= connect= service= status=503 bytes=
christian@christian-R480-R431-R481:~/Documentos/heroku/portafolio/venv$ 

Benjamin Manns 的解决方案对我有用,尽管我还需要一个额外的步骤。

据此,在Procfile解决方案被推送后,运行以下命令:

heroku ps:scale web=1

网站现在应该正确加载。

有关推送到 heroku git repo 的更多帮助,请参阅

添加proc文件并运行以下命令

$ heroku ps:scale web=1

您是否阅读过Heroku 指南以设置 Django 应用程序 你的 Procfile 是什么样的?

您的项目应该有一个名为Procfile的文件,其内容应类似于

web: gunicorn hellodjango.wsgi

您的Procfile必须如下所示(对于 python):

网页:python myApp.py 运行服务器 0.0.0.0:$PORT

如果你在 python/django

heroku logs --tail

如果您无法找到错误并修复然后尝试做,

首先运行看看它是否在herokus local工作

heroku local web

我的是在 Procfile 中指定 django wsgi.py 文件的路径

查看他们的示例https://github.com/heroku/python-getting-started

Procfile 看起来与此类似

web: gunicorn projectname.wsgi --log-file -

如果未安装,您可能必须安装 gunicorn 并将其添加到 requirements.txt

然后Git添加并提交,然后推送到heroku

git push heroku master

然后扩展您的应用程序

heroku ps:scale web=1

我执行了以下步骤以使其正常工作。

1)我不得不将我的 Procfile 移动到最外面的文件夹。

2)然后我不得不将我的 Procfile 更改为

web: gunicorn projectname.projectname.wsgi

3) 同样在我的 wsgi 文件中,我必须将设置路径更改为

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.projectname.settings')

4)在我的 settings.py 文件中,我必须更改我的 ROOT_URLCONF

ROOT_URLCONF = 'projectname.projectname.urls'

5)在 urls.py 我不得不改变我的路径

from projectname.applicationname import urls as app_urls

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(app_urls)),
]

6)最后我做到了

git push heroku master
heroku ps:scale web=1

在进行所有这些更改之后,heroku 就像一个魅力一样工作。 但它不能在 Windows 上本地工作,因为我在某处读到 Windows 没有 gunicorn。

当我在本地尝试python projectname/manage.py runserver它说

ModuleNotFoundError: No module named 'projectname.projectname'

所以为了在本地运行它,我必须恢复上面的所有步骤:P

就我而言,这是 dynos 配置错误,我的意思是,如果您不是高级会员,请查看 heroku dashbord 是否可用于您的应用程序的 dynos。 如果您没有估计,您可以通过单击指标来检查。 运行命令 $ heroku ps:scale web=1 将您的代码推送到 master 中。

我收到应用程序错误我检查了 heroku 日志 --tail ,在desc="No web processes running"主要是由于 Procfile 而发生的,所以在 Procfile 中我忘记在“web:”之后留出空间

web: gunicorn hellodjango.wsgi --log-file - 

所以检查你的 Procfile {这个文件将在项目文件夹内的根文件夹中创建}

虽然已经说过,但请检查Procfileruntime.txtrequirements.txt是否在最外层文件夹中。 (这些文件将放在manage.py的位置)

我的情况有点不同。 我已经解决了所有问题并在 Heroku 上部署了我的应用程序。 我之前在 Heroku 上部署了 3 4 python 应用程序。 根文件夹中有 Procfile 和 requirements.txt。

这一次,我几乎尝试了所有指南和 StackOverflow 的答案,但一无所获。 然后在web:gunicorn之后添加一个空格,它工作得很好。

以前我使用的是web:gunicorn wsgi:app

我只是将其更改为web: gunicorn wsgi:app它就像一个魅力

在此处输入图像描述

确保您的测功机正在运行,否则您也会收到上述错误。 然后你必须在heroku上手动启动dynos,而heroku会自动为你启动,但有时你必须在heroku上手动运行。 单击配置测功机按钮==>切换测功机按钮,您的测功机将启动。

在 Heroku 仪表板中检查您的测功机配置。 它可能是 wsgi 模块之前的错误应用程序名称。 我有一个旧项目的应用名称,而不是我尝试使用的名称:

web: gunicorn old_project_app.wsgi

更正您的 Procfile 并将其推送到 Heroku。 您可能需要删除并重新创建该文件。 然后在测功机配置中应该是这样的:

web: gunicorn new_project_app.wsgi

确保 Procfile 的拼写。 它应该是“Procfile”而不是“procfile”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM