Django 部署 - 没有网络进程

时间:2021-01-27 03:56:17

标签: django heroku deployment heroku-cli django-deployment

我使用 Django 3.1.5 创建了一个应用程序,但由于某种原因,它没有正确部署。我会分享我所做的和拥有的。

我已经设置了我的 Procfile 和我的 requirements.txt,我按照我在网站上的说明进行了部署,但我仍然遇到错误。

computer setting image and Procfile

在我的 settings.py 上,我有这个:

# on the top of the file
import django_heroku

# on the bottom of the file
STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_DIRS = [
    os.path.join(BASE_DIR, 'todo/static')
]

LOGIN_URL = '/login'

# Activate Django-Heroku.
django_heroku.settings(locals())

资料

web: gunicorn todowoo.wsgi

完成部署后出现此错误

应用错误 应用程序发生错误,无法提供您的页面。如果您是应用程序所有者,请检查您的日志以了解详细信息。 heroku 日志 --tail 详情

详情如下:

2021-01-27T03:16:07.704192+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=djangotodowoo.herokuapp.com request_id=babd8359-3dfe-4df9-8ce6-5243de91b159 fwd="66.31.116.154" dyno= 
connect= service= status=503 bytes= protocol=https
2021-01-27T03:16:07.912002+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=djangotodowoo.herokuapp.com request_id=4114d73f-f15f-4d35-9c1b-e25225a36bde fwd="66.31.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-27T03:16:10.630599+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=djangotodowoo.herokuapp.com request_id=9426a4a1-061f-41b6-a9a0-46190b752b60 fwd="66.31.116.154" dyno= 
connect= service= status=503 bytes= protocol=https
2021-01-27T03:16:10.760576+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=djangotodowoo.herokuapp.com request_id=cb4c8412-eaa2-482a-9daa-e5126f2a89e3 fwd="66.31.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-27T03:16:11.398016+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=djangotodowoo.herokuapp.com request_id=8f025699-e7b8-4ca8-9795-36ad7754ef9f fwd="66.31.116.154" dyno= 
connect= service= status=503 bytes= protocol=https
2021-01-27T03:16:11.548669+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=djangotodowoo.herokuapp.com request_id=d1c4ed4e-bbf6-43ff-88d0-2788f268fbe3 fwd="66.31.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-27T03:18:44.000000+00:00 app[api]: Build started by user lenilunderman@gmail.com
2021-01-27T03:19:12.176886+00:00 app[api]: Release v6 created by user lenilunderman@gmail.com
2021-01-27T03:19:12.176886+00:00 app[api]: Deploy 6caa0271 by user lenilunderman@gmail.com
2021-01-27T03:19:22.000000+00:00 app[api]: Build succeeded

我尝试运行 heroku ps:scale web=1 并且我得到了这个:

Scaling dynos... !
 !    Couldn't find that process type (web).

知道如何解决这个问题吗?谢谢。

1 个答案:

答案 0 :(得分:1)

我最近遇到了类似的情况。我按照这些命令成功地将 django 应用程序部署到 heroku 中

  • 首先确保您有 requirements.txtProcfile

  • Procfile中,内容是这样的

  • web: python manage.py runserver 0.0.0.0:$PORT

  • 并运行 python manage.py collectstatic 以确保没有来自 collectstatic 的错误

  • 然后这些命令在 cmd

  • heroku 登录

  • 然后从浏览器登录

  • git 初始化

  • heroku git:remote -a app_name

  • git add .

  • git commit -am "第一次提交"

  • git push heroku main

  • heroku 运行 python manage.py migrate

  • heroku 打开