使用 gunicorn 在 Django-Heroku App 上获取 error=H14
Getting error=H14 on Django-Heroku App using gunicorn
我正在尝试将我的 django-react 应用程序部署到 heroku。部署进行得很顺利,但是 heroku open
我遇到了应用程序错误。
heroku logs --tail
显示以下内容
简而言之:错误代码 H14“没有网络进程 运行”
详细:
> 2021-01-22T18:12:32.000000+00:00 app[api]: Build started by user
> johndoe@gmail.com 2021-01-22T18:13:42.032970+00:00 app[api]:
> Deploy f905f66c by user johndoe@gmail.com
> 2021-01-22T18:13:42.032970+00:00 app[api]: Running release v3
> commands by user johndoe@gmail.com
> 2021-01-22T18:13:42.786292+00:00 app[api]: Starting process with
> command `/bin/sh -c 'if curl $HEROKU_RELEASE_LOG_STREAM --silent
> --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then 2021-01-22T18:13:42.786292+00:00 app[api]: chmod u+x /tmp/log-stream
> 2021-01-22T18:13:42.786292+00:00 app[api]: /tmp/log-stream /bin/sh -c
> '"'"'python manage.py migrate --no-input'"'"'
> 2021-01-22T18:13:42.786292+00:00 app[api]: else
> 2021-01-22T18:13:42.786292+00:00 app[api]: python manage.py migrate
> --no-input 2021-01-22T18:13:42.786292+00:00 app[api]: fi'` by user johndoe@gmail.com 2021-01-22T18:13:50.874352+00:00
> heroku[release.2135]: Starting process with command `/bin/sh -c 'if
> curl
> https://heroku-release-output.s3.amazonaws.com/log-stream?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ3LIQ2SWG7V76SVQ%2F20210122%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210122T181342Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=5fc1b225b8a71466d45518b4029f165af938e8c5d766033b8a335481d6a46e84
> --silent --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then 2021-01-22T18:13:51.619515+00:00 heroku[release.2135]: State changed from starting to up
> 2021-01-22T18:13:54.000000+00:00 app[api]: Build succeeded
> 2021-01-22T18:13:55.388498+00:00 app[release.2135]:
> /app/.heroku/python/lib/python3.6/site-packages/environ/environ.py:630:
> UserWarning: /app/recipemanager/.env doesn't exist - if you're not
> configuring your environment separately, create one.
> 2021-01-22T18:13:55.388523+00:00 app[release.2135]: "environment
> separately, create one." % env_file) 2021-01-22T18:13:56.208813+00:00
> app[release.2135]: Operations to perform:
> 2021-01-22T18:13:56.208840+00:00 app[release.2135]: Apply all
> migrations: admin, auth, contenttypes, knox, recipes, sessions
> 2021-01-22T18:13:56.247988+00:00 app[release.2135]: Running
> migrations: 2021-01-22T18:13:56.248243+00:00 app[release.2135]: No
> migrations to apply. 2021-01-22T18:13:56.708681+00:00
> heroku[release.2135]: Process exited with status 0
> 2021-01-22T18:13:56.751146+00:00 heroku[release.2135]: State changed
> from up to complete 2021-01-22T18:13:58.083076+00:00 app[api]: Release
> v3 created by user johndoe@gmail.com
> 2021-01-22T18:15:21.067440+00:00 heroku[router]: at=error code=H14
> desc="No web processes running" method=GET path="/"
> host=wholesumapp.herokuapp.com
> request_id=5ea478c4-e333-412d-9605-0c02a660f819 fwd="95.90.240.137"
> dyno= connect= service= status=503 bytes= protocol=https
> 2021-01-22T18:15:21.637645+00:00 heroku[router]: at=error code=H14
> desc="No web processes running" method=GET path="/favicon.ico"
> host=wholesumapp.herokuapp.com
> request_id=eada688a-c875-44df-97ef-b6c06cff95d4 fwd="95.90.240.137"
> dyno= connect= service= status=503 bytes= protocol=https
导致它的步骤:
git push heroku master
heroku ps:scale web=1
heroku open
我的个人资料:
release: python manage.py makemigrations --no-input
release: python manage.py migrate --no-input
web: gunicorn mainapp.wsgi
我的文件结构:
project
accounts
frontend
mainapp
__init.py__
.env
settings.py
wsgi.py
staticfiles
__init.py__
manage.py
package-lock.json
package.json
Pipfile
Pipfile.lock
Procfile
webpack.config.js
我的 settings.py 文件:
import django_heroku
import os
from pathlib import Path
import environ
import dj_database_url
env = environ.Env()
environ.Env.read_env()
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = env("SECRET_KEY")
DEBUG = env.bool('DEBUG', default=False)
ALLOWED_HOSTS = ['projectapp.herokuapp.com', '127.0.0.1', 'localhost']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'frontend',
'knox',
'accounts'
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ('knox.auth.TokenAuthentication',)
}
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mainapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'mainapp.wsgi.application'
DATABASES = {}
DATABASES = {'default': dj_database_url.config(default=env("DATABASE_URL"))}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '../frontend/static/frontend/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())
我假设我的 Procfile 一定有问题,但话又说回来我真的不知道。
我是一个完全的初学者,我会很高兴收到各种帮助和反馈。
提前致谢。
生活中有很多次,解决方案就在眼前。我只需要再次禁用和启用 dyno,我是通过资源选项卡下 heroku 仪表板的 GUI 完成的。禁用它,点击保存,再次启用,点击保存,然后瞧瞧。
我的代码没有任何问题,至少在这方面没有问题。
在这个过程中学到了很多东西,我将留下我为这个问题所经历的小清单。希望这对某人有帮助。同样,这是用于将带有 gunicorn 的 django 应用程序部署到 heroku,我不知道其中有多少适用于其他框架。此外,可能还有其他方法,但这对我有用。
Procfile
Procfile
不能有像 .txt 这样的扩展名
Procfile
应该与 manage.py 一起位于您要部署到 heroku 的目录的根目录下
- 确保
Procfile
中的 Web 进程指向您的 wsgi.py
所在的正确目录
达诺斯
- 在
git push heroku master
之后确保测功机是 运行 heroku ps:scale web=1
- 您可以使用
heroku ps
检查 Dyno 状态,在我的例子中是 'no dyno on app',简单的 disable/enable 通过 heroku 仪表板解决了这个问题。
希望这对某人有所帮助,如果您有其他问题,请随时发表评论。保重。
我正在尝试将我的 django-react 应用程序部署到 heroku。部署进行得很顺利,但是 heroku open
我遇到了应用程序错误。
heroku logs --tail
显示以下内容
简而言之:错误代码 H14“没有网络进程 运行”
详细:
> 2021-01-22T18:12:32.000000+00:00 app[api]: Build started by user
> johndoe@gmail.com 2021-01-22T18:13:42.032970+00:00 app[api]:
> Deploy f905f66c by user johndoe@gmail.com
> 2021-01-22T18:13:42.032970+00:00 app[api]: Running release v3
> commands by user johndoe@gmail.com
> 2021-01-22T18:13:42.786292+00:00 app[api]: Starting process with
> command `/bin/sh -c 'if curl $HEROKU_RELEASE_LOG_STREAM --silent
> --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then 2021-01-22T18:13:42.786292+00:00 app[api]: chmod u+x /tmp/log-stream
> 2021-01-22T18:13:42.786292+00:00 app[api]: /tmp/log-stream /bin/sh -c
> '"'"'python manage.py migrate --no-input'"'"'
> 2021-01-22T18:13:42.786292+00:00 app[api]: else
> 2021-01-22T18:13:42.786292+00:00 app[api]: python manage.py migrate
> --no-input 2021-01-22T18:13:42.786292+00:00 app[api]: fi'` by user johndoe@gmail.com 2021-01-22T18:13:50.874352+00:00
> heroku[release.2135]: Starting process with command `/bin/sh -c 'if
> curl
> https://heroku-release-output.s3.amazonaws.com/log-stream?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ3LIQ2SWG7V76SVQ%2F20210122%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210122T181342Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=5fc1b225b8a71466d45518b4029f165af938e8c5d766033b8a335481d6a46e84
> --silent --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then 2021-01-22T18:13:51.619515+00:00 heroku[release.2135]: State changed from starting to up
> 2021-01-22T18:13:54.000000+00:00 app[api]: Build succeeded
> 2021-01-22T18:13:55.388498+00:00 app[release.2135]:
> /app/.heroku/python/lib/python3.6/site-packages/environ/environ.py:630:
> UserWarning: /app/recipemanager/.env doesn't exist - if you're not
> configuring your environment separately, create one.
> 2021-01-22T18:13:55.388523+00:00 app[release.2135]: "environment
> separately, create one." % env_file) 2021-01-22T18:13:56.208813+00:00
> app[release.2135]: Operations to perform:
> 2021-01-22T18:13:56.208840+00:00 app[release.2135]: Apply all
> migrations: admin, auth, contenttypes, knox, recipes, sessions
> 2021-01-22T18:13:56.247988+00:00 app[release.2135]: Running
> migrations: 2021-01-22T18:13:56.248243+00:00 app[release.2135]: No
> migrations to apply. 2021-01-22T18:13:56.708681+00:00
> heroku[release.2135]: Process exited with status 0
> 2021-01-22T18:13:56.751146+00:00 heroku[release.2135]: State changed
> from up to complete 2021-01-22T18:13:58.083076+00:00 app[api]: Release
> v3 created by user johndoe@gmail.com
> 2021-01-22T18:15:21.067440+00:00 heroku[router]: at=error code=H14
> desc="No web processes running" method=GET path="/"
> host=wholesumapp.herokuapp.com
> request_id=5ea478c4-e333-412d-9605-0c02a660f819 fwd="95.90.240.137"
> dyno= connect= service= status=503 bytes= protocol=https
> 2021-01-22T18:15:21.637645+00:00 heroku[router]: at=error code=H14
> desc="No web processes running" method=GET path="/favicon.ico"
> host=wholesumapp.herokuapp.com
> request_id=eada688a-c875-44df-97ef-b6c06cff95d4 fwd="95.90.240.137"
> dyno= connect= service= status=503 bytes= protocol=https
导致它的步骤:
git push heroku master
heroku ps:scale web=1
heroku open
我的个人资料:
release: python manage.py makemigrations --no-input
release: python manage.py migrate --no-input
web: gunicorn mainapp.wsgi
我的文件结构:
project
accounts
frontend
mainapp
__init.py__
.env
settings.py
wsgi.py
staticfiles
__init.py__
manage.py
package-lock.json
package.json
Pipfile
Pipfile.lock
Procfile
webpack.config.js
我的 settings.py 文件:
import django_heroku
import os
from pathlib import Path
import environ
import dj_database_url
env = environ.Env()
environ.Env.read_env()
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = env("SECRET_KEY")
DEBUG = env.bool('DEBUG', default=False)
ALLOWED_HOSTS = ['projectapp.herokuapp.com', '127.0.0.1', 'localhost']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'frontend',
'knox',
'accounts'
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ('knox.auth.TokenAuthentication',)
}
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mainapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'mainapp.wsgi.application'
DATABASES = {}
DATABASES = {'default': dj_database_url.config(default=env("DATABASE_URL"))}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '../frontend/static/frontend/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())
我假设我的 Procfile 一定有问题,但话又说回来我真的不知道。 我是一个完全的初学者,我会很高兴收到各种帮助和反馈。
提前致谢。
生活中有很多次,解决方案就在眼前。我只需要再次禁用和启用 dyno,我是通过资源选项卡下 heroku 仪表板的 GUI 完成的。禁用它,点击保存,再次启用,点击保存,然后瞧瞧。
我的代码没有任何问题,至少在这方面没有问题。
在这个过程中学到了很多东西,我将留下我为这个问题所经历的小清单。希望这对某人有帮助。同样,这是用于将带有 gunicorn 的 django 应用程序部署到 heroku,我不知道其中有多少适用于其他框架。此外,可能还有其他方法,但这对我有用。
Procfile
Procfile
不能有像 .txt 这样的扩展名Procfile
应该与 manage.py 一起位于您要部署到 heroku 的目录的根目录下
- 确保
Procfile
中的 Web 进程指向您的wsgi.py
所在的正确目录
达诺斯
- 在
git push heroku master
之后确保测功机是 运行heroku ps:scale web=1
- 您可以使用
heroku ps
检查 Dyno 状态,在我的例子中是 'no dyno on app',简单的 disable/enable 通过 heroku 仪表板解决了这个问题。
- 在
希望这对某人有所帮助,如果您有其他问题,请随时发表评论。保重。