使用--preload运行gunicrn_start.sh:错误清空模块名称

时间:2014-10-14 14:56:37

标签: django gunicorn

我有一个django项目,带着gunicorn。我有以下gunicorn_start:

#! /bin/bash

NAME="ostabs2"
DJANGODIR=/srv/osmium/ostabs2
SOCKFILE=/srv/osmium/run/gunicorn.sock
USER=tabuser
GROUP=webapps
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=ostabs2.settings
DANGO_WSGI_MODULE=ostabs2.wsgi

echo "Starting $NAME as 'whoami'"

cd $DJANGODIR
source /srv/osmium/venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

exec gunicorn ${DJANGO_WSGI_MODULE}:application \
  --preload \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --log-level=debug \
  --bind=unix:$SOCKFILE \
  --log-file=ostabsgun.log

运行

gunicorn ostabs2.wsgi:application
命令行上的

工作正常,但gunicorn_start脚本给出:

Traceback (most recent call last):
  File "/srv/osmium/venv/bin/gunicorn", line 11, in <module>
    sys.exit(run())
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 185, in run
    super(Application, self).run()
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
    Arbiter(self).run()
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 57, in __init__
    self.setup(app)
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 113, in setup
    self.app.wsgi()
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 66, in wsgi
    self.callable = self.load()
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/srv/osmium/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 356, in import_app
    __import__(module)
ValueError: Empty module name

什么会导致此错误?项目中是否存在错误,或者缺少依赖项?我检查了所有文件和目录的用户权限,tabuser具有完全的读/写访问权限。如何找出导致此问题的原因?

更新:我已经按照this问题的建议,数据库定义是正确的(我可以在本地和服务器上运行syyncdb)。安装的应用程序部分中没有空字符串,我已将整个应用程序中的引用删除到不再使用的库中 还有什么可以导致这个错误吗?

0 个答案:

没有答案