我将我的项目部署到heroku,我创建了我的应用程序推送到heroku,调整我的postgreSQL凭据,迁移数据库,但是当我"运行heroku打开"时,它显示我:应用程序错误无法提供您的网页。
项目结构:
├── apps
│ ├── home
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── inventario
│ ├── ordenes_trabajo
│ ├── reportes
│ ├── sucursales
│ ├── usuarios
│ └── ventas_cotizaciones
├── __init__.py
├── manage.py
├── prerequirements_install.txt
├── Procfile
├── proyecto_www
│ ├── db.sqlite3
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── README.md
│ ├── settings
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
├── requirements.txt
├── static
│ ├── css
│ ├── datepicker
│ ├── fonts
│ ├── img
│ ├── js
│ ├── pdfs
│ ├── plantilla
│ ├── sass
│ └── syntaxhighlighter
├── templates
│ ├── base.html
│ ├── base_list.html
│ ├── datatableview
│ └── includes
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proyecto_www.settings.staging")
application = Cling(get_wsgi_application())
我的设置中的参数是:
BASE_DIR = Path(__file__).ancestor(3)
DEBUG = True
ALLOWED_HOSTS = ['*']
STATICFILES_DIRS=(BASE_DIR,'static')
STATIC_URL = '/static/'
WSGI_APPLICATION = 'proyecto_www.wsgi.application'
STATIC_ROOT = 'staticfiles'
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
Procfile内容
web: gunicorn proyecto_www.wsgi
我的主要urls.py
from django.conf.urls import include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
urlpatterns=[
url(r'^admin/',include(admin.site.urls)),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^', include('apps.home.urls',namespace='home')),
url(r'^', include('apps.usuarios.urls',namespace='usuarios')),
url(r'^', include('apps.inventario.urls',namespace='inventario')),
url(r'^', include('apps.ventas_cotizaciones.urls',namespace='ventas_cotizaciones')),
url(r'^', include('apps.ordenes_trabajo.urls',namespace='ordenes_trabajo')),
url(r'^', include('apps.sucursales.urls', namespace='sucursales')),
url(r'^', include('apps.reportes.urls', namespace='reportes')),
]
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)
我的heroku日志是:
2016-01-16T16:44:23.261629+00:00 app[web.1]: [2016-01-16 16:44:23 +0000] [3] [INFO] Shutting down: Master
2016-01-16T16:44:23.261703+00:00 app[web.1]: [2016-01-16 16:44:23 +0000] [3] [INFO] Reason: Worker failed to boot.
2016-01-16T16:44:23.285624+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=crisefd-concesionario-www.herokuapp.com request_id=195b1b27-df0c-44e2-9e27-c59fd4de17ee fwd="181.52.225.237" dyno=web.1 connect=0ms service=27099ms status=503 bytes=0
2016-01-16T16:44:24.074843+00:00 heroku[web.1]: State changed from up to crashed
2016-01-16T16:44:24.074843+00:00 heroku[web.1]: State changed from crashed to starting
2016-01-16T16:44:24.062495+00:00 heroku[web.1]: Process exited with status 3
2016-01-16T16:44:27.849620+00:00 heroku[web.1]: Starting process with command `gunicorn proyecto_www.wsgi`
2016-01-16T16:44:30.462707+00:00 app[web.1]: [2016-01-16 16:44:30 +0000] [3] [INFO] Starting gunicorn 19.4.1
2016-01-16T16:44:30.503069+00:00 app[web.1]: [2016-01-16 16:44:30 +0000] [10] [INFO] Booting worker with pid: 10
2016-01-16T16:44:30.463623+00:00 app[web.1]: [2016-01-16 16:44:30 +0000] [3] [INFO] Listening at: http://0.0.0.0:56568 (3)
2016-01-16T16:44:30.463891+00:00 app[web.1]: [2016-01-16 16:44:30 +0000] [3] [INFO] Using worker: sync
2016-01-16T16:44:30.480976+00:00 app[web.1]: [2016-01-16 16:44:30 +0000] [9] [INFO] Booting worker with pid: 9
2016-01-16T16:44:31.712682+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-01-16T16:44:31.712691+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-01-16T16:44:31.712698+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-01-16T16:44:31.712706+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-01-16T16:44:31.714018+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
2016-01-16T16:44:31.714025+00:00 app[web.1]: File "/app/proyecto_www/wsgi.py", line 13, in <module>
2016-01-16T16:44:31.714032+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
2016-01-16T16:44:31.714039+00:00 app[web.1]: File "/app/proyecto_www/wsgi.py", line 13, in <module>
2016-01-16T16:44:31.712683+00:00 app[web.1]: self.callable = self.load()
2016-01-16T16:44:31.712691+00:00 app[web.1]: "'DJANGO_SETTINGS_MODULE' environment variable must be set "
2016-01-16T16:44:31.712699+00:00 app[web.1]: self.callable = self.load()
2016-01-16T16:44:31.712706+00:00 app[web.1]: "'DJANGO_SETTINGS_MODULE' environment variable must be set "
2016-01-16T16:44:31.714019+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2016-01-16T16:44:31.714026+00:00 app[web.1]: from whitenoise.django import DjangoWhiteNoise
2016-01-16T16:44:31.714033+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2016-01-16T16:44:31.714040+00:00 app[web.1]: from whitenoise.django import DjangoWhiteNoise
2016-01-16T16:44:31.712671+00:00 app[web.1]: [2016-01-16 16:44:31 +0000] [9] [ERROR] Exception in worker process:
2016-01-16T16:44:31.712684+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-01-16T16:44:31.712692+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-01-16T16:44:31.712700+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-01-16T16:44:31.712707+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-01-16T16:44:31.714020+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-01-16T16:44:31.714027+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-01-16T16:44:31.714034+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-01-16T16:44:31.714041+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-01-16T16:44:31.712676+00:00 app[web.1]: Traceback (most recent call last):
2016-01-16T16:44:31.712684+00:00 app[web.1]: return self.load_wsgiapp()
2016-01-16T16:44:31.712693+00:00 app[web.1]: Traceback (most recent call last):
2016-01-16T16:44:31.712700+00:00 app[web.1]: return self.load_wsgiapp()
2016-01-16T16:44:31.712803+00:00 app[web.1]: [2016-01-16 16:44:31 +0000] [9] [INFO] Worker exiting (pid: 9)
2016-01-16T16:44:31.714020+00:00 app[web.1]: self.callable = self.load()
2016-01-16T16:44:31.714027+00:00 app[web.1]: "'DJANGO_SETTINGS_MODULE' environment variable must be set "
2016-01-16T16:44:31.714034+00:00 app[web.1]: self.callable = self.load()
2016-01-16T16:44:31.714048+00:00 app[web.1]: "'DJANGO_SETTINGS_MODULE' environment variable must be set "
2016-01-16T16:44:31.712678+00:00 app[web.1]: worker.init_process()
2016-01-16T16:44:31.712686+00:00 app[web.1]: return util.import_app(self.app_uri)
2016-01-16T16:44:31.712695+00:00 app[web.1]: worker.init_process()
2016-01-16T16:44:31.712702+00:00 app[web.1]: return util.import_app(self.app_uri)
2016-01-16T16:44:31.714014+00:00 app[web.1]: Traceback (most recent call last):
2016-01-16T16:44:31.714022+00:00 app[web.1]: return self.load_wsgiapp()
2016-01-16T16:44:31.714029+00:00 app[web.1]: Traceback (most recent call last):
2016-01-16T16:44:31.714036+00:00 app[web.1]: return self.load_wsgiapp()
2016-01-16T16:44:31.714203+00:00 app[web.1]: [2016-01-16 16:44:31 +0000] [10] [INFO] Worker exiting (pid: 10)
2016-01-16T16:44:31.712677+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
2016-01-16T16:44:31.712685+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-16T16:44:31.712694+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
2016-01-16T16:44:31.712701+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-16T16:44:31.714012+00:00 app[web.1]: [2016-01-16 16:44:31 +0000] [10] [ERROR] Exception in worker process:
2016-01-16T16:44:31.714021+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-01-16T16:44:31.714028+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-01-16T16:44:31.714035+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-01-16T16:44:31.714049+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-01-16T16:44:31.712679+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
2016-01-16T16:44:31.712687+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2016-01-16T16:44:31.712696+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
2016-01-16T16:44:31.712703+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2016-01-16T16:44:31.714015+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
2016-01-16T16:44:31.714023+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-16T16:44:31.714030+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
2016-01-16T16:44:31.714037+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-16T16:44:31.751764+00:00 app[web.1]: [2016-01-16 16:44:31 +0000] [3] [INFO] Shutting down: Master
2016-01-16T16:44:31.712680+00:00 app[web.1]: self.load_wsgi()
2016-01-16T16:44:31.712688+00:00 app[web.1]: __import__(module)
2016-01-16T16:44:31.712696+00:00 app[web.1]: self.load_wsgi()
2016-01-16T16:44:31.712703+00:00 app[web.1]: __import__(module)
2016-01-16T16:44:31.714016+00:00 app[web.1]: worker.init_process()
2016-01-16T16:44:31.714023+00:00 app[web.1]: return util.import_app(self.app_uri)
2016-01-16T16:44:31.714030+00:00 app[web.1]: worker.init_process()
2016-01-16T16:44:31.714037+00:00 app[web.1]: return util.import_app(self.app_uri)
2016-01-16T16:44:31.751871+00:00 app[web.1]: [2016-01-16 16:44:31 +0000] [3] [INFO] Reason: Worker failed to boot.
2016-01-16T16:44:31.712681+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
2016-01-16T16:44:31.712689+00:00 app[web.1]: File "/app/proyecto_www/wsgi.py", line 13, in <module>
2016-01-16T16:44:31.712697+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
2016-01-16T16:44:31.712704+00:00 app[web.1]: File "/app/proyecto_www/wsgi.py", line 13, in <module>
2016-01-16T16:44:31.714017+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
2016-01-16T16:44:31.714024+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2016-01-16T16:44:31.714031+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
2016-01-16T16:44:31.714038+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2016-01-16T16:44:31.712681+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2016-01-16T16:44:31.712690+00:00 app[web.1]: from whitenoise.django import DjangoWhiteNoise
2016-01-16T16:44:31.712698+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2016-01-16T16:44:31.712705+00:00 app[web.1]: from whitenoise.django import DjangoWhiteNoise
2016-01-16T16:44:31.714018+00:00 app[web.1]: self.load_wsgi()
2016-01-16T16:44:31.714025+00:00 app[web.1]: __import__(module)
2016-01-16T16:44:31.714032+00:00 app[web.1]: self.load_wsgi()
2016-01-16T16:44:31.714039+00:00 app[web.1]: __import__(module)
2016-01-16T16:44:32.508739+00:00 heroku[web.1]: State changed from up to crashed
2016-01-16T16:44:32.502339+00:00 heroku[web.1]: Process exited with status 3
2016-01-16T16:44:31.496313+00:00 heroku[web.1]: State changed from starting to up
答案 0 :(得分:4)
我认为您还没有发布您的实际wsgi.py
文件。您获得的例外情况来自whitenoise
,但您发布的文件使用dj_static
。
为避免错误,您需要确定以下行:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proyecto_www.settings.staging")
导入whitenoise.django
之前。
这是由于Django中的一个错误,将在以后的版本中修复。