在这里、这里和这里使用以下教程和 github 模板,我花了大部分时间与 django 和夹层搏斗。现在我有一个mezzanine-project
,叫做uccdev
,当我运行python manage.py runserver
时,它运行得很好。
现在,我想使用gunicorn
和foreman
来处理事物,以便以后可以将我的项目上传到 heroku。
根据乔什·芬尼的说法,
添加下面的Procfile使Mezzanine在Gunicorn上运行,并成功让Heroku为我的静态文件提供服务。首先,如果运行 collectstatic 以确保所有静态媒体都位于应用中的适当位置,其次它运行 Gunicorn 服务器。
web: python manage.py collectstatic --noinput; python manage.py run_gunicorn -b 0.0.0.0:$PORT
我在settings.py
中添加了gunicorn
作为应用程序,但是每次我在终端中运行foreman start
时,它都会立即关闭并显示以下错误消息。
Pythoness-998:uccdev gersande$ foreman start
01:02:45 web.1 | started with pid 7592
01:02:45 web.1 | /usr/local/lib/python2.7/site-packages/mezzanine/utils/conf.py:48: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.
01:02:45 web.1 | warn("You haven't defined the ALLOWED_HOSTS settings, which "
01:02:46 web.1 | 0 static files copied, 549 unmodified.
01:02:46 web.1 | /usr/local/lib/python2.7/site-packages/mezzanine/utils/conf.py:48: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.
01:02:46 web.1 | warn("You haven't defined the ALLOWED_HOSTS settings, which "
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Starting gunicorn 18.0
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Listening at: http://0.0.0.0:5000 (7594)
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Using worker: sync
01:02:46 web.1 | 2013-12-23 01:02:46 [7597] [INFO] Booting worker with pid: 7597
01:02:46 web.1 | 2013-12-23 01:02:46 [7597] [ERROR] Exception in worker process:
01:02:46 web.1 | Traceback (most recent call last):
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
01:02:46 web.1 | worker.init_process()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
01:02:46 web.1 | self.wsgi = self.app.wsgi()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
01:02:46 web.1 | self.callable = self.load()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 142, in load
01:02:46 web.1 | return mod.make_command_wsgi_application(self.admin_media_path)
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
01:02:46 web.1 | reload_django_settings()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 109, in reload_django_settings
01:02:46 web.1 | logging_config_func(settings.LOGGING)
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 803, in dictConfig
01:02:46 web.1 | dictConfigClass(config).configure()
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 509, in configure
01:02:46 web.1 | raise ValueError("dictionary doesn't specify a version")
01:02:46 web.1 | ValueError: dictionary doesn't specify a version
01:02:46 web.1 | Traceback (most recent call last):
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
01:02:46 web.1 | worker.init_process()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
01:02:46 web.1 | self.wsgi = self.app.wsgi()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
01:02:46 web.1 | self.callable = self.load()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 142, in load
01:02:46 web.1 | return mod.make_command_wsgi_application(self.admin_media_path)
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
01:02:46 web.1 | reload_django_settings()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 109, in reload_django_settings
01:02:46 web.1 | logging_config_func(settings.LOGGING)
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 803, in dictConfig
01:02:46 web.1 | dictConfigClass(config).configure()
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 509, in configure
01:02:46 web.1 | raise ValueError("dictionary doesn't specify a version")
01:02:46 web.1 | ValueError: dictionary doesn't specify a version
01:02:46 web.1 | 2013-12-23 01:02:46 [7597] [INFO] Worker exiting (pid: 7597)
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Shutting down: Master
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Reason: Worker failed to boot.
01:02:46 web.1 | exited with code 3
01:02:46 system | sending SIGTERM to all processes
SIGTERM received
任何想法如何为字典指定版本?
来自用户渣滓的答案 - 为 gunicorn 创建主管脚本的正确方法?姜戈 1.6
我在 settings.py 中添加了以下内容:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
}