簡體   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