DEBUG上的500服务器错误= Django中的假,带有gunicorn和whitenoise,heroku

时间:2016-08-14 01:08:27

标签: python django debugging heroku deployment

正如所有其他基于调试的问题似乎在这里,我的应用程序在切换到debug = false后产生500错误。我跟踪this关于使用heroku部署django项目的视频,直到我到达DEBUG。

我已经尝试过了......

ALLOWED_HOSTS = ['*'] # didn't change anything
adding a trailing forward slash '/' to links # didn't change anything

8/24/2016

added /favicon.ico url # eliminated related error
added favicon.02c31ae25a91.ico file # eliminated related error

--- settings.py ---

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

DEBUG = False

ALLOWED_HOSTS = ['.appname.herokuapp.com'] # appname is just a placeholder here

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'apps.home',
    'apps.quiz',
    'apps.store',
    'apps.accounts',
]

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 = 'first_project.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 = 'first_project.wsgi.application'

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_URL = '/static/'

# added for heroku
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATIC_ROOT = os.path.join((BASE_DIR), 'static')

--- urls.py ---

from django.conf.urls import patterns, url
from . import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
    url(r'^show/(?P<chord_id>\w+)/$', views.show, name='show'),
    url(r'^chords$', views.chords, name='chords'),
    url(r'^review_us$', views.review_us, name='review_us'),
    url(r'^submit_review$', views.SubmitReview.as_view(), name='submit_review'),
    url(r'^reviews$', views.reviews, name='reviews'),
    url(r'^discovery$', views.discovery, name='discovery')
)

--- views.py ---

def index(request):
    # return HttpResponse("You are looking at question number %s." % question_id)

    # if int(question_id) == 1:
    #   return HttpResponse('<h1>Page found!</h1>')
    # else:
    #   raise Http404

    # if int(question_id) == 1:
    #   return HttpResponse('<h1> Page found! </h1>')
    # else:
    #   return HttpResponseNotFound('<h1> Page not found! </h1>')

    context = {
        'assertions': [
        { 'id': 1, 'content': 'Django Landing Page'},
        { 'id': 2, 'content': 'Second value'},
        { 'id': 3, 'content': 'Third value'},
        { 'id': 4, 'content': 'Fourth value'},
            ]
        }

    return render(request, 'home/index.html', context)

--- heroku logs ---

2016-08-23T23:24:30.258910+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-08-23T23:24:30.277985+00:00 heroku[web.1]: Restarting
2016-08-23T23:24:30.278655+00:00 heroku[web.1]: State changed from up to startin
g
2016-08-23T23:24:33.838679+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-23T23:24:34.619593+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-23T23:24:35.632013+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-23T23:24:35.636996+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Handling signal: term
2016-08-23T23:24:35.640739+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-23T23:24:35.696136+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Shutting down: Master
2016-08-23T23:24:35.610297+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:4293 (3)
2016-08-23T23:24:35.610447+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Using worker: sync
2016-08-23T23:24:35.614711+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-23T23:24:35.609886+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-23T23:24:35.646281+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-23T23:24:35.889214+00:00 heroku[web.1]: Process exited with status 0
2016-08-23T23:24:36.004541+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-23T23:25:54.160914+00:00 heroku[api]: Starting process with command `pyt
hon manage.py collectstatic` by brian.eddow@gmail.com
2016-08-23T23:25:58.277888+00:00 heroku[run.3353]: Awaiting client
2016-08-23T23:25:58.304948+00:00 heroku[run.3353]: Starting process with command
 `python manage.py collectstatic`
2016-08-23T23:25:58.481426+00:00 heroku[run.3353]: State changed from starting t
o up
2016-08-23T23:26:08.355832+00:00 heroku[run.3353]: Process exited with status 1
2016-08-23T23:26:08.366477+00:00 heroku[run.3353]: State changed from up to comp
lete
2016-08-23T23:26:20.356441+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=20a28fca-d7f9-406b-9110-06f0f8e265f4 fwd="10
8.201.188.39" dyno=web.1 connect=0ms service=75ms status=500 bytes=239
2016-08-23T23:30:12.593525+00:00 heroku[api]: Deploy bcdede2 by brian.eddow@gmai
l.com
2016-08-23T23:30:12.593630+00:00 heroku[api]: Release v83 created by brian.eddow
@gmail.com
2016-08-23T23:30:12.827280+00:00 heroku[slug-compiler]: Slug compilation started

2016-08-23T23:30:12.827285+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-08-23T23:30:12.875797+00:00 heroku[web.1]: Restarting
2016-08-23T23:30:12.878934+00:00 heroku[web.1]: State changed from up to startin
g
2016-08-23T23:30:15.128700+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-23T23:30:15.675480+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-23T23:30:15.675491+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-23T23:30:15.675492+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [3] [IN
FO] Handling signal: term
2016-08-23T23:30:15.676931+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [3] [IN
FO] Shutting down: Master
2016-08-23T23:30:15.769076+00:00 heroku[web.1]: Process exited with status 0
2016-08-23T23:30:16.401830+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-23T23:30:18.414541+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:20560 (3)
2016-08-23T23:30:18.414678+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [3] [IN
FO] Using worker: sync
2016-08-23T23:30:18.413989+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-23T23:30:18.419387+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-23T23:30:18.451925+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-23T23:30:20.092572+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-23T23:30:21.599823+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=d04b82a0-845b-4098-b78e-95538974b682 fwd="10
8.201.188.39" dyno=web.1 connect=0ms service=59ms status=500 bytes=239
2016-08-24T00:03:49.213687+00:00 heroku[web.1]: State changed from up to down
2016-08-24T00:03:49.213151+00:00 heroku[web.1]: Idling
2016-08-24T00:03:51.783907+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-24T00:03:52.532466+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-24T00:03:52.528309+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-24T00:03:52.528563+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [3] [IN
FO] Handling signal: term
2016-08-24T00:03:52.644328+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [3] [IN
FO] Shutting down: Master
2016-08-24T00:03:52.782407+00:00 heroku[web.1]: Process exited with status 0
2016-08-24T00:58:31.329461+00:00 heroku[web.1]: Unidling
2016-08-24T00:58:31.329760+00:00 heroku[web.1]: State changed from down to start
ing
2016-08-24T00:58:35.650617+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-24T00:58:37.722538+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-24T00:58:37.723001+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:58399 (3)
2016-08-24T00:58:37.723085+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [3] [IN
FO] Using worker: sync
2016-08-24T00:58:37.807193+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-24T00:58:37.727390+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-24T00:58:39.340476+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-24T00:58:40.556179+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=41fd5fa1-d91b-4c9b-8988-b18102ca8dbe fwd="10
8.201.188.39" dyno=web.1 connect=1ms service=62ms status=500 bytes=239
2016-08-24T01:33:02.714290+00:00 heroku[web.1]: Idling
2016-08-24T01:33:02.714953+00:00 heroku[web.1]: State changed from up to down
2016-08-24T01:33:06.080166+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-24T01:33:06.850885+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-24T01:33:06.866811+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [3] [IN
FO] Handling signal: term
2016-08-24T01:33:06.850898+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-24T01:33:06.880540+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [3] [IN
FO] Shutting down: Master
2016-08-24T01:33:07.004257+00:00 heroku[web.1]: Process exited with status 0
2016-08-24T19:49:46.766158+00:00 heroku[web.1]: Unidling
2016-08-24T19:49:46.766448+00:00 heroku[web.1]: State changed from down to start
ing
2016-08-24T19:49:51.590527+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-24T19:49:53.555121+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-24T19:49:53.555711+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [3] [IN
FO] Using worker: sync
2016-08-24T19:49:53.555605+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:38921 (3)
2016-08-24T19:49:53.617284+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-24T19:49:53.559598+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-24T19:49:55.155379+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-24T19:49:56.927053+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=ca7b4765-90cb-4908-ad56-3ae39f535777 fwd="10
8.201.188.39" dyno=web.1 connect=1ms service=59ms status=500 bytes=239
2016-08-24T19:49:57.471151+00:00 heroku[router]: at=info method=GET path="/favic
on.ico" host=chordjam.herokuapp.com request_id=196b6576-1aed-45d1-b21d-c3f316f82
02e fwd="108.201.188.39" dyno=web.1 connect=0ms service=30ms status=302 bytes=27
8
2016-08-24T19:49:57.581950+00:00 heroku[router]: at=info method=GET path="/stati
c/favicon.02c31ae25a91.ico" host=chordjam.herokuapp.com request_id=5ce248c4-e25f
-4c69-badf-7bd395876493 fwd="108.201.188.39" dyno=web.1 connect=0ms service=3ms
status=404 bytes=305
2016-08-24T19:51:47.100779+00:00 heroku[slug-compiler]: Slug compilation started

2016-08-24T19:51:47.100784+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-08-24T19:51:47.083765+00:00 heroku[web.1]: Restarting
2016-08-24T19:51:47.084557+00:00 heroku[web.1]: State changed from up to startin
g
2016-08-24T19:51:46.883892+00:00 heroku[api]: Release v84 created by brian.eddow
@gmail.com
2016-08-24T19:51:46.883892+00:00 heroku[api]: Deploy 9843b18 by brian.eddow@gmai
l.com
2016-08-24T19:51:49.386648+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-24T19:51:49.960873+00:00 app[web.1]: [2016-08-24 19:51:49 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-24T19:51:50.096207+00:00 app[web.1]: [2016-08-24 19:51:50 +0000] [3] [IN
FO] Shutting down: Master
2016-08-24T19:51:49.961498+00:00 app[web.1]: [2016-08-24 19:51:49 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-24T19:51:49.960884+00:00 app[web.1]: [2016-08-24 19:51:49 +0000] [3] [IN
FO] Handling signal: term
2016-08-24T19:51:50.216478+00:00 heroku[web.1]: Process exited with status 0
2016-08-24T19:51:51.873593+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-24T19:51:54.552846+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-24T19:51:54.548218+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [3] [IN
FO] Using worker: sync
2016-08-24T19:51:54.548216+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:13574 (3)
2016-08-24T19:51:54.592965+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-24T19:51:54.547456+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-24T19:51:55.606463+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-24T19:51:56.802850+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=06f8f828-0823-48c2-9f84-bc81bc0e86b8 fwd="10
8.201.188.39" dyno=web.1 connect=0ms service=131ms status=500 bytes=239

我在这里阅读了许多其他问题和回答,尝试了大多数提供的解决方案。如果我可以提供任何其他代码来帮助别人帮助我,请告诉我,此时我觉得我在黑暗中拍摄。

2016年8月24日 - 从heroku日志开始,看起来它在slug编译后重新启动,但我对日志不够熟悉,无法准确读取这些错误。

0 个答案:

没有答案