gunicorn_django -b 0.0.0.0 project_name / settings / production.py

时间:2013-06-28 17:05:30

标签: django gunicorn

$ python manage.py run_gunicorn 0.0.0.0:80 --settings = project_name.settings.production

< - 它运行了,好的。

但是, $ gunicorn_django -b 0.0.0.0:80 project_name / settings / production.py


Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 473, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 106, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/djangoapp.py", line 102, in load
    return mod.make_wsgi_application()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/django_wsgi.py", line 36, in make_wsgi_application
    if get_validation_errors(s):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 166, in get_app_errors
    self._populate()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 72, in _populate
    self.load_app(app_name, True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 94, in load_app
    app_module = import_module(app_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
> ImportError: No module named accounts
2013-06-29 01:56:53 [30859] [INFO] Worker exiting (pid: 30859)
2013-06-29 01:56:53 [30854] [INFO] Shutting down: Master
2013-06-29 01:56:53 [30854] [INFO] Reason: Worker failed to boot.

我该如何解决这个问题? 我想在守护进程上运行。

感谢。

2 个答案:

答案 0 :(得分:1)

这看起来像是与您的PYTHONPATH相关的问题。尝试使用gunicorn的--pythonpath将包含accounts模块的路径添加到python路径。

如果你有较新的gunicorn / Django版本使用gunicorn通过management command应该是优先的方式 - 对于这样的问题它应该更安全。

答案 1 :(得分:0)

尝试使用gunicorn而不是django_gunicorn运行您的django应用程序:

$ gunicorn mydjangoproject.wsgi:application

还有另一种修复gunicorn_django脚本的解决方案,请参阅here。从gunicorn 18.0升级到19.1.1时遇到了这个问题。干杯!