0

Django Webサイトにgunicornをインストールして使用しようとしましたが、次のエラーが発生します。

$ python manage.py run_gunicorn
2012-12-19 01:46:50 [6877] [INFO] Starting gunicorn 0.16.1
2012-12-19 01:46:50 [6877] [INFO] Listening at: http://127.0.0.1:8000 (6877)
2012-12-19 01:46:50 [6877] [INFO] Using worker: sync
2012-12-19 01:46:50 [6878] [INFO] Booting worker with pid: 6878
2012-12-19 01:46:51 [6878] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 469, in spawn_worker
    worker.init_process()
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/base.py", line 99, in wsgi
    self.callable = self.load()
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 134, in load
    return mod.make_command_wsgi_application(self.admin_media_path)
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 116, in make_command_wsgi_application
    return AdminMediaHandler(make_wsgi_application(), admin_mediapath)
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 36, in make_wsgi_application
    if get_validation_errors(s):
  File "... project folder .../venv/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
    self._populate()
  File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/loading.py", line 61, in _populate
    self.load_app(app_name, True)
  File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "... project folder .../venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "... project folder .../venv/lib/python2.7/site-packages/south/models.py", line 2, in <module>
    from south.db import DEFAULT_DB_ALIAS
  File "... project folder .../venv/lib/python2.7/site-packages/south/db/__init__.py", line 81, in <module>
    db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
Traceback (most recent call last):
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 469, in spawn_worker
    worker.init_process()
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/base.py", line 99, in wsgi
    self.callable = self.load()
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 134, in load
    return mod.make_command_wsgi_application(self.admin_media_path)
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 116, in make_command_wsgi_application
    return AdminMediaHandler(make_wsgi_application(), admin_mediapath)
  File "... project folder .../venv/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 36, in make_wsgi_application
    if get_validation_errors(s):
  File "... project folder .../venv/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
    self._populate()
  File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/loading.py", line 61, in _populate
    self.load_app(app_name, True)
  File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "... project folder .../venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "... project folder .../venv/lib/python2.7/site-packages/south/models.py", line 2, in <module>
    from south.db import DEFAULT_DB_ALIAS
  File "... project folder .../venv/lib/python2.7/site-packages/south/db/__init__.py", line 81, in <module>
    db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
2012-12-19 01:46:51 [6878] [INFO] Worker exiting (pid: 6878)
2012-12-19 01:46:51 [6877] [INFO] Shutting down: Master
2012-12-19 01:46:51 [6877] [INFO] Reason: Worker failed to boot.

同様のエラーがあるこの質問を見つけましたが、内部のDATABASESdictsettings.pyは正しいようです:

DATABASES = {
    'default': {
        'ENGINE': 'postgresql_psycopg2',
        ...
    }
}

私は自分のに入れgunicornましたINSTALLED_APPSrunserverうまく動作します。southそれ自体でもうまくいくようです。

コメントアウトすることで、gunicornを機能させることができましsouthINSTALLED_APPS。これは、本番環境にデプロイするときにできると思います。何が起こっている?

(その価値のために、私はDjango 1.3.2を使用しています)

4

1 に答える 1

2

データベース バックエンドのフル パスを使用してみてください。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        ...
    }
}
于 2012-12-19T15:42:04.867 に答える