我的应用似乎在本地运行良好的" heroku本地网络"
当我把它推到heroku时,它会消失,但似乎崩溃了。我认为这是Procfile的一个问题,但我现在不确定。我已经阅读了有关使用django部署的heroku文档,并阅读了许多YouTube教程。我只是缺乏理解这里问题的经验。
heroku日志:
2016-12-08T12:00:53.156174+00:00 heroku[slug-compiler]: Slug compilation started
2016-12-08T12:00:53.156184+00:00 heroku[slug-compiler]: Slug compilation finished
2016-12-08T12:00:53.309072+00:00 heroku[web.1]: State changed from crashed to starting
2016-12-08T12:00:58.260750+00:00 heroku[web.1]: Starting process with command `gunicorn demonstration.wsgi`
2016-12-08T12:01:00.654433+00:00 app[web.1]: bash: gunicorn: command not found
2016-12-08T12:01:00.734784+00:00 heroku[web.1]: Process exited with status 127
2016-12-08T12:01:00.747378+00:00 heroku[web.1]: State changed from starting to crashed
2016-12-08T12:01:17.045591+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=git-api-example.herokuapp.com request_id=5849efad-36bb-4fe3-9b08-b284d54c4dbf fwd="REDACTED" dyno= connect= service= status=503 bytes=
2016-12-08T12:01:18.314297+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=git-api-example.herokuapp.com request_id=c76d3c5f-19f2-48ac-8266-52627cdfac55 fwd="REDACTED" dyno= connect= service= status=503 bytes=
(github-api-app) ➜ demonstration git:(master)
Procfile:
demonstration git:(master) cat Procfile
web: gunicorn demonstration.wsgi
Procfile下面的目录结构:
(github-api-app)➜演示git :(主)树演示
demonstration
├── __init__.py
├── old_settings.py
├── __pycache__
│ ├── __init__.cpython-35.pyc
│ ├── settings.cpython-35.pyc
│ ├── urls.cpython-35.pyc
│ └── wsgi.cpython-35.pyc
├── settings
│ ├── __init__.py
│ ├── local.py
│ ├── production.py
│ └── __pycache__
│ ├── __init__.cpython-35.pyc
│ ├── local.cpython-35.pyc
│ └── production.cpython-35.pyc
├── urls.py
└── wsgi.py
3 directories, 14 files
(github-api-app) ➜ demonstration git:(master)
生产设置:
"""
Django settings for demonstration project.
Generated by 'django-admin startproject' using Django 1.10.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'REMOVED_SECRET_KEY'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'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 = 'demonstration.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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 = 'demonstration.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
我很好奇,如果它是ALLOWED_HOSTS,但我不相信。我添加了一个特定的主机,但后来默认为一个空列表,在这种情况下,我认为这是一个合理的默认值?