2

$ 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.

我怎么解决这个问题?我想在守护进程上运行。

谢谢。

4

2 回答 2

1

这看起来像是与您的PYTHONPATH. 尝试accounts使用 gunicorn 的--pythonpath.

如果您有较新的 gunicorn/Django 版本,通过管理命令使用 gunicorn应该是首选方式 - 对于此类问题应该更安全。

于 2013-06-28T19:52:16.820 回答
0

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

$ gunicorn mydjangoproject.wsgi:application

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

于 2015-01-14T19:43:06.693 回答