我正在尝试将我的Django网站部署到Heroku上但是当我加载我的网站时,我收到此错误:
应用程序错误:
应用程序中发生错误,您的页面无法执行 提供服务。请稍后再试。
如果您是应用程序所有者,请查看日志以获取详细信息。
所以我输入heroku logs
这就是我得到的:
2015-02-20T15:49:36.361800+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
2015-02-20T15:49:36.361809+00:00 app[web.1]: return util.import_app(self.app_uri)
2015-02-20T15:49:36.361801+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2015-02-20T15:49:36.361803+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-02-20T15:49:36.361805+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-02-20T15:49:36.361808+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-02-20T15:49:36.361811+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-02-20T15:49:36.361815+00:00 app[web.1]: application = get_wsgi_application()
2015-02-20T15:49:36.361817+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
2015-02-20T15:49:36.361812+00:00 app[web.1]: __import__(module)
2015-02-20T15:49:36.361819+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 20, in setup
2015-02-20T15:49:36.361814+00:00 app[web.1]: File "/app/django_test/wsgi.py", line 14, in <module>
2015-02-20T15:49:36.361818+00:00 app[web.1]: django.setup()
2015-02-20T15:49:36.361823+00:00 app[web.1]: logging_config_func(logging_settings)
2015-02-20T15:49:36.361821+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2015-02-20T15:49:36.361822+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/log.py", line 87, in configure_logging
2015-02-20T15:49:36.361829+00:00 app[web.1]: '%r: %s' % (name, e))
2015-02-20T15:49:36.361830+00:00 app[web.1]: ValueError: Unable to configure handler 'default': [Errno 2] No such file or directory: '/app/logs/mylog.log'
2015-02-20T15:49:36.361929+00:00 app[web.1]: [2015-02-20 15:49:36 +0000] [9] [INFO] Worker exiting (pid: 9)
2015-02-20T15:49:36.361825+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/logging/config.py", line 794, in dictConfig
2015-02-20T15:49:36.361828+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/logging/config.py", line 576, in configure
2015-02-20T15:49:36.361826+00:00 app[web.1]: dictConfigClass(config).configure()
2015-02-20T15:49:36.488086+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
2015-02-20T15:49:36.488087+00:00 app[web.1]: worker.init_process()
2015-02-20T15:49:36.488090+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2015-02-20T15:49:36.488092+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-02-20T15:49:36.488093+00:00 app[web.1]: self.callable = self.load()
2015-02-20T15:49:36.488089+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
2015-02-20T15:49:36.488103+00:00 app[web.1]: File "/app/django_test/wsgi.py", line 14, in <module>
2015-02-20T15:49:36.488099+00:00 app[web.1]: return util.import_app(self.app_uri)
2015-02-20T15:49:36.488100+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-02-20T15:49:36.488101+00:00 app[web.1]: __import__(module)
2015-02-20T15:49:36.488082+00:00 app[web.1]: [2015-02-20 15:49:36 +0000] [10] [ERROR] Exception in worker process:
2015-02-20T15:49:36.488076+00:00 app[web.1]: /app/static/
2015-02-20T15:49:36.488084+00:00 app[web.1]: Traceback (most recent call last):
2015-02-20T15:49:36.488106+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
2015-02-20T15:49:36.488108+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 20, in setup
2015-02-20T15:49:36.488131+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/logging/config.py", line 576, in configure
2015-02-20T15:49:36.488111+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/log.py", line 87, in configure_logging
2015-02-20T15:49:36.488113+00:00 app[web.1]: logging_config_func(logging_settings)
2015-02-20T15:49:36.488095+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-02-20T15:49:36.488133+00:00 app[web.1]: ValueError: Unable to configure handler 'default': [Errno 2] No such file or directory: '/app/logs/mylog.log'
2015-02-20T15:49:36.488140+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2015-02-20T15:49:36.488136+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
2015-02-20T15:49:36.488096+00:00 app[web.1]: return self.load_wsgiapp()
2015-02-20T15:49:36.488141+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-02-20T15:49:36.488143+00:00 app[web.1]: self.callable = self.load()
2015-02-20T15:49:36.488097+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-02-20T15:49:36.488148+00:00 app[web.1]: return util.import_app(self.app_uri)
2015-02-20T15:49:36.488104+00:00 app[web.1]: application = get_wsgi_application()
2015-02-20T15:49:36.488153+00:00 app[web.1]: File "/app/django_test/wsgi.py", line 14, in <module>
2015-02-20T15:49:36.488110+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2015-02-20T15:49:36.488158+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 20, in setup
2015-02-20T15:49:36.488157+00:00 app[web.1]: django.setup()
2015-02-20T15:49:36.488160+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2015-02-20T15:49:36.488150+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-02-20T15:49:36.488107+00:00 app[web.1]: django.setup()
2015-02-20T15:49:36.488151+00:00 app[web.1]: __import__(module)
2015-02-20T15:49:36.488163+00:00 app[web.1]: logging_config_func(logging_settings)
2015-02-20T15:49:36.488114+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/logging/config.py", line 794, in dictConfig
2015-02-20T15:49:36.488132+00:00 app[web.1]: '%r: %s' % (name, e))
2015-02-20T15:49:36.488129+00:00 app[web.1]: dictConfigClass(config).configure()
2015-02-20T15:49:36.488164+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/logging/config.py", line 794, in dictConfig
2015-02-20T15:49:36.488165+00:00 app[web.1]: dictConfigClass(config).configure()
2015-02-20T15:49:36.488168+00:00 app[web.1]: '%r: %s' % (name, e))
2015-02-20T15:49:36.488139+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
2015-02-20T15:49:36.488135+00:00 app[web.1]: Traceback (most recent call last):
2015-02-20T15:49:36.488137+00:00 app[web.1]: worker.init_process()
2015-02-20T15:49:36.488167+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/logging/config.py", line 576, in configure
2015-02-20T15:49:36.507131+00:00 app[web.1]: super(Application, self).run()
2015-02-20T15:49:36.507076+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
2015-02-20T15:49:36.488146+00:00 app[web.1]: return self.load_wsgiapp()
2015-02-20T15:49:36.488144+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-02-20T15:49:36.507001+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-02-20T15:49:36.506915+00:00 app[web.1]: Traceback (most recent call last):
2015-02-20T15:49:36.506970+00:00 app[web.1]: sys.exit(run())
2015-02-20T15:49:36.507154+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2015-02-20T15:49:36.507531+00:00 app[web.1]: self.reap_workers()
2015-02-20T15:49:36.507476+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 210, in handle_chld
2015-02-20T15:49:36.507269+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2015-02-20T15:49:36.488147+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-02-20T15:49:36.488154+00:00 app[web.1]: application = get_wsgi_application()
2015-02-20T15:49:36.488171+00:00 app[web.1]: [2015-02-20 15:49:36 +0000] [10] [INFO] Worker exiting (pid: 10)
2015-02-20T15:49:36.507190+00:00 app[web.1]: Arbiter(self).run()
2015-02-20T15:49:36.507453+00:00 app[web.1]: time.sleep(0.1)
2015-02-20T15:49:36.507056+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-02-20T15:49:36.507382+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 338, in stop
2015-02-20T15:49:36.507715+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-02-20T15:49:36.488161+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/log.py", line 87, in configure_logging
2015-02-20T15:49:36.488170+00:00 app[web.1]: ValueError: Unable to configure handler 'default': [Errno 2] No such file or directory: '/app/logs/mylog.log'
2015-02-20T15:49:36.507292+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 293, in halt
2015-02-20T15:49:36.507213+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 197, in run
2015-02-20T15:49:36.507642+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-02-20T15:49:36.507358+00:00 app[web.1]: self.stop()
2015-02-20T15:49:36.488155+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
2015-02-20T15:49:36.506923+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-02-20T15:49:36.507554+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 455, in reap_workers
2015-02-20T15:49:37.304329+00:00 heroku[web.1]: State changed from up to crashed
2015-02-20T15:49:37.292485+00:00 heroku[web.1]: Process exited with status 1
2015-02-20T15:49:36.299215+00:00 heroku[web.1]: State changed from starting to up
2015-02-20T15:49:42.613930+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=article-django.herokuapp.com request_id=5e18c64f-98b1-4f2b-a88b-c9d93a0908e9 fwd="173.3.238.36" dyno=web.1 connect=5001ms service= status=503 bytes=
我查看了这个日志,似乎主要问题是'/app/logs/mylog.log'
不存在。如果是这样的话,我该如何创建该文件?
编辑:这是我的settings.py文件的LOGGING部分:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins':{
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'email_backend':
'django.core.mail.backends.filebased.EmailBackend',
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propogate': True,
},
}
}
答案 0 :(得分:0)
/app
是将您的应用程序放在Heroku上的目录。尝试在项目的根目录中添加logs
目录并将其推送到Heroku - 然后目录将存在,因此应该创建日志文件而不会出现问题。