Django app成功部署到Heroku但是立即崩溃了Heroku open或Heroku本地命令

时间:2016-01-06 07:09:43

标签: python django heroku

我能够创建一个Heroku应用程序并将我的项目部署到Heroku而不会出错。此外,我的应用程序在本地运行。

当我在命令行中运行命令Heroku ps时:web.1:crashed 2016/01/06 01:30:10

当我运行Heroku打开时,我收到默认错误消息:

  

应用程序中发生错误,无法提供您的页面。请稍后重试。如果您是应用程序所有者,请检查日志以获取详细信息。

使用命令:Heroku local

web.1  | [2016-01-06 07:04:52 +0000] [33239] [INFO] Starting gunicorn 19.4.5
web.1  | [2016-01-06 07:04:52 +0000] [33239] [INFO] Listening at: http://0.0.0.0:5000 (33239)
web.1  | [2016-01-06 07:04:52 +0000] [33239] [INFO] Using worker: sync
web.1  | [2016-01-06 07:04:52 +0000] [33242] [INFO] Booting worker with pid: 33242

我的目录设置如下: directory

Settings.py

import os
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production


# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'REMOVED'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

CRISPY_TEMPLATE_PACK = 'bootstrap3'
# Application definition

INSTALLED_APPS = [
    #default django
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    #third party
    'crispy_forms',
    #my apps
    'mysite',
]

MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['mysite/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 = 'mysite.wsgi.application'


# Database

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'myproject3',
        'USER': 'myproject3user',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '',
    }
}


# Password validation

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',
    },
]

PASSWORD_HASHERS = (
        'django.contrib.auth.hashers.PBKDF2PasswordHasher',
        'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
        'django.contrib.auth.hashers.BCryptPasswordHasher',
        'django.contrib.auth.hashers.SHA1PasswordHasher',
        'django.contrib.auth.hashers.MD5PasswordHasher',
        'django.contrib.auth.hashers.CryptPasswordHasher',
)

# Internationalization


#AUTH_PROFILE_MODULE = 'mysite.UserProfile'

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)


STATIC_URL = '/static/'

import dj_database_url
DATABASES['default'] = dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']

DEBUG = False

try:
    from .local_settings import *
except ImportError:
    pass

wsgi.py

import os

from django.core.wsgi import get_wsgi_application

from dj_static import Cling

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = Cling(get_wsgi_application())

Procfile

web: gunicorn mysite.wsgi --preload

requirements.txt

dj-database-url==0.3.0
dj-static==0.0.6
Django==1.9.1
django-crispy-forms==1.5.2
django-toolbelt==0.0.1
gunicorn==19.4.5
heroku==0.1.4
postgres==2.2.1
psycopg2==2.6.1
python-dateutil==1.5
requests==2.9.1
static3==0.6.1
waitress==0.8.10
wheel==0.24.0
whitenoise==2.0.6

runtime.txt

python-2.7.10

我花了相当多的时间来尝试调试这个问题并经历了无数的教程,所以任何帮助都会非常感激!

Heroku Logs

2016-01-06T12:14:27.531220+00:00 heroku[web.1]: State changed from starting to crashed

2016-01-06T12:14:27.546362+00:00 heroku[web.1]: Process exited with status 1
2016-01-06T17:51:55.821211+00:00 heroku[web.1]: Starting process with command `gunicorn mysite.wsgi --preload`
2016-01-06T17:51:59.829953+00:00 app[web.1]: Traceback (most recent call last):
2016-01-06T17:51:59.839957+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2016-01-06T17:51:59.840035+00:00 app[web.1]:     sys.exit(run())
2016-01-06T17:51:59.840068+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2016-01-06T17:51:59.840117+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2016-01-06T17:51:59.840227+00:00 app[web.1]:     super(Application, self).run()
2016-01-06T17:51:59.840311+00:00 app[web.1]:     Arbiter(self).run()
2016-01-06T17:51:59.840163+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
2016-01-06T17:51:59.840248+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2016-01-06T17:51:59.840335+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 61, in __init__
2016-01-06T17:51:59.840379+00:00 app[web.1]:     self.setup(app)
2016-01-06T17:51:59.840401+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 119, in setup
2016-01-06T17:51:59.840476+00:00 app[web.1]:     self.app.wsgi()
2016-01-06T17:51:59.840497+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-01-06T17:51:59.840540+00:00 app[web.1]:     self.callable = self.load()
2016-01-06T17:51:59.840561+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-01-06T17:51:59.840624+00:00 app[web.1]:     return self.load_wsgiapp()
2016-01-06T17:51:59.840646+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2016-01-06T17:51:59.840689+00:00 app[web.1]:     return util.import_app(self.app_uri)
2016-01-06T17:51:59.840711+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 357, in import_app
2016-01-06T17:51:59.840812+00:00 app[web.1]:     __import__(module)
2016-01-06T17:51:59.840833+00:00 app[web.1]:   File "/app/mysite/wsgi.py", line 17, in <module>
2016-01-06T17:51:59.840869+00:00 app[web.1]:     application = Cling(get_wsgi_application())
2016-01-06T17:51:59.840891+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2016-01-06T17:51:59.840948+00:00 app[web.1]:     django.setup()
2016-01-06T17:51:59.840971+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
2016-01-06T17:51:59.841009+00:00 app[web.1]:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2016-01-06T17:51:59.841031+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
2016-01-06T17:51:59.841074+00:00 app[web.1]:     self._setup(name)
2016-01-06T17:51:59.841145+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup
2016-01-06T17:51:59.841188+00:00 app[web.1]:     self._wrapped = Settings(settings_module)
2016-01-06T17:51:59.841209+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 99, in __init__
2016-01-06T17:51:59.841325+00:00 app[web.1]:     mod = importlib.import_module(self.SETTINGS_MODULE)
2016-01-06T17:51:59.841348+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
2016-01-06T17:51:59.841389+00:00 app[web.1]:     __import__(name)
2016-01-06T17:51:59.841478+00:00 app[web.1]: ImportError: No module named prod
2016-01-06T17:52:01.141159+00:00 heroku[web.1]: Process exited with status 1
2016-01-06T17:52:01.152836+00:00 heroku[web.1]: State changed from starting to crashed

我一直在努力解决这个问题并一直在研究其他类似的服务,但Heroku似乎是唯一一个与Django良好互动的人。

0 个答案:

没有答案