必须设置使用DJANGO_SETTINGS_MODULE的Heroku应用程序崩溃

时间:2016-05-26 19:16:10

标签: python django heroku

我的应用程序在Heroku中崩溃了。我查看了StackOverflow上的类似问题并看到调整我的wsgi文件,但它没有帮助。我相信Django设置模块已经设置好了,所以我不确定为什么它不能解决它。

这是我的wsgi.py文件

"""
WSGI config for automated_survey project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "twilio_sample_project.settings.production")
#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "prompt.settings")

from whitenoise.django import DjangoWhiteNoise

#application = get_wsgi_application()
#application = DjangoWhiteNoise(application)
application = DjangoWhiteNoise(get_wsgi_application())

These are the logs:

on2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-05-26T18:53:24.780434+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-05-26T18:53:24.830385+00:00 app[web.1]: [2016-05-26 18:53:24 +0000] [9] [ERROR] Exception in worker process:
2016-05-26T18:53:24.780557+00:00 app[web.1]: [2016-05-26 18:53:24 +0000] [10] [INFO] Worker exiting (pid: 10)
2016-05-26T18:53:24.830394+00:00 app[web.1]: Traceback (most recent call last):
2016-05-26T18:53:24.830395+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2016-05-26T18:53:24.830396+00:00 app[web.1]:     worker.init_process()
2016-05-26T18:53:24.830397+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2016-05-26T18:53:24.830398+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2016-05-26T18:53:24.830399+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-05-26T18:53:24.830399+00:00 app[web.1]:     self.callable = self.load()
2016-05-26T18:53:24.830400+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-05-26T18:53:24.830400+00:00 app[web.1]:     return self.load_wsgiapp()
2016-05-26T18:53:24.830401+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2016-05-26T18:53:24.830402+00:00 app[web.1]:     return util.import_app(self.app_uri)
2016-05-26T18:53:24.830402+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2016-05-26T18:53:24.830403+00:00 app[web.1]:     __import__(module)
2016-05-26T18:53:24.830404+00:00 app[web.1]:   File "/app/twilio_sample_project/wsgi.py", line 13, in <module>
2016-05-26T18:53:24.830405+00:00 app[web.1]:     from whitenoise.django import DjangoWhiteNoise
2016-05-26T18:53:24.830405+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-05-26T18:53:24.830406+00:00 app[web.1]:     "'DJANGO_SETTINGS_MODULE' environment variable must be set "
2016-05-26T18:53:24.830407+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-05-26T18:53:24.830408+00:00 app[web.1]: Traceback (most recent call last):
2016-05-26T18:53:24.830408+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2016-05-26T18:53:24.830409+00:00 app[web.1]:     worker.init_process()
2016-05-26T18:53:24.830410+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2016-05-26T18:53:24.830410+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2016-05-26T18:53:24.830411+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-05-26T18:53:24.830412+00:00 app[web.1]:     self.callable = self.load()
2016-05-26T18:53:24.830412+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-05-26T18:53:24.830413+00:00 app[web.1]:     return self.load_wsgiapp()
2016-05-26T18:53:24.830414+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2016-05-26T18:53:24.830414+00:00 app[web.1]:     return util.import_app(self.app_uri)
2016-05-26T18:53:24.830415+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2016-05-26T18:53:24.830416+00:00 app[web.1]:     __import__(module)
2016-05-26T18:53:24.830417+00:00 app[web.1]:     from whitenoise.django import DjangoWhiteNoise
2016-05-26T18:53:24.830416+00:00 app[web.1]:   File "/app/twilio_sample_project/wsgi.py", line 13, in <module>
2016-05-26T18:53:24.830418+00:00 app[web.1]:     "'DJANGO_SETTINGS_MODULE' environment variable must be set "
2016-05-26T18:53:24.830556+00:00 app[web.1]: [2016-05-26 18:53:24 +0000] [9] [INFO] Worker exiting (pid: 9)
2016-05-26T18:53:24.830419+00:00 app[web.1]: ImproperlyConfigured: 'DJANGO_SETTINGS_MODULE' environment variable must be set before importing 'whitenoise.django'
2016-05-26T18:53:24.862307+00:00 app[web.1]: Traceback (most recent call last):
2016-05-26T18:53:24.862321+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2016-05-26T18:53:24.862355+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2016-05-26T18:53:24.830418+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/django.py", line 20, in <module>
2016-05-26T18:53:24.862395+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2016-05-26T18:53:24.862352+00:00 app[web.1]:     sys.exit(run())
2016-05-26T18:53:24.862485+00:00 app[web.1]:     super(Application, self).run()
2016-05-26T18:53:24.862507+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2016-05-26T18:53:24.862570+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 201, in run
2016-05-26T18:53:24.862430+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
2016-05-26T18:53:24.862568+00:00 app[web.1]:     Arbiter(self).run()
2016-05-26T18:53:24.862619+00:00 app[web.1]:     self.halt(reason=inst.reason, exit_status=inst.exit_status)
2016-05-26T18:53:24.862699+00:00 app[web.1]:     self.stop()
2016-05-26T18:53:24.862623+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 297, in halt
2016-05-26T18:53:24.862731+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 342, in stop
2016-05-26T18:53:24.862884+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2016-05-26T18:53:24.862794+00:00 app[web.1]:     time.sleep(0.1)
2016-05-26T18:53:24.862820+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 214, in handle_chld
2016-05-26T18:53:24.863056+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2016-05-26T18:53:24.862881+00:00 app[web.1]:     self.reap_workers()
2016-05-26T18:53:24.862987+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2016-05-26T18:53:25.896309+00:00 heroku[web.1]: State changed from starting to crashed
2016-05-26T18:53:25.867011+00:00 heroku[web.1]: Process exited with status 1
2016-05-26T18:53:27.306772+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=damp-coast-30004.herokuapp.com request_id=865ba1a5-da36-4800

0 个答案:

没有答案