我正在使用virtualenv将我的网站从Mezzanine迁移到使用virtualenv在Debian机器上运行的Wagtail,但在设置Wagtail之后,当我在wagtail文件夹中运行# gunicorn_django
时,我获得以下内容的用户权限和来源错误讯息:
Traceback (most recent call last):
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 102, in load
make_default_env(self.cfg)
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 62, in make_default_env
raise RuntimeError("django project not found")
RuntimeError: django project not found
Traceback (most recent call last):
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 102, in load
make_default_env(self.cfg)
File "/home/user/userblog/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 62, in make_default_env
raise RuntimeError("django project not found")
RuntimeError: django project not found
2014-06-09 10:41:27 [2774] [INFO] Worker exiting (pid: 2774)
2014-06-09 10:41:28 [2769] [INFO] Shutting down: Master
2014-06-09 10:41:28 [2769] [INFO] Reason: Worker failed to boot.
据我所知,我的夹层设置并没有什么不同,我知道Wagtail也是基于Django的。有谁知道问题出在哪里?
答案 0 :(得分:4)
gunicorn_django是deprecated since Gunicorn 18。如果可能,您应该使用Django的WSGI接口。请参阅Django with Gunicorn docs。
然而,这就是说,当使用gunicorn_django,其中设置不在settings.py中,而是在模块中,您应该能够通过指定相关设置文件的虚线路径来使其工作 - 例如在mywagtailproject
文件夹中,mywagtailproject/settings/production.py
文件(请注意,mywagtailproject文件夹将具有相同名称的mywagtailproject子文件夹):
gunicorn_django --settings=mywagtailproject.settings.production --pythonpath=/pathto/mywagtailproject
您可能需要也可能不需要设置--pythonpath
参数。