嗨我正在尝试将我的django 1.4.1应用程序与Gunicorn 0.14.6集成。我开始在命令行gunicorn服务器就像这样 -Django Gunicorn wsgi
gunicorn -c /home/code/gunicorn_config.py
我得到这个回溯 -
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 459, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 99, in init_process
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 101, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 24, in load
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 292, in import_app
app = eval(obj, mod.__dict__)
File "<string>", line 1, in <module>
NameError: name 'application' is not defined
我在哪里去了?这是什么application
变量&我需要在哪里修改?
此外,由于我使用Django1.4.1我有一个wsgi.py
文件已经在我的项目,我需要改变这种状况?
UPDATE:这里是我的gunicorn_config.py
文件的内容 -
import os
import sys
import multiprocessing
def app_path():
sys.path.append('/home/code/po/')
sys.path.append('/home/code/po/ball/')
return
def num_cpus():
cpus = 0
try:
cpus = os.sysconf("SC_NPROCESSORS_ONLN")
except:
cpus = multiprocessing.cpu_count()
if cpus: return cpus
else: return 3
#defining the behavior of gunicorn
app_path()
bind = "127.0.0.1:8080"
workers = num_cpus()*2 + 1
debug = True
daemon = False
accesslog = '/home/code/logs/guni_access.log'
errorlog = '/home/code/logs/guni_error.log'
loglevel = 'debug'
django_settings = '/home/code/po/po/'
pythonpath = '/home/code/po/'
@moopet - 我甚至不认为wsgi.py
文件被调用时,如何使gunicorn挑选文件?
可以添加gunicorn_config.py文件太运行你的应用程序。看起来你的wsgi.py路径不对。 – yilmazhuseyin
粘贴在wsgi.py文件它应该是一个应用程序定义 – moopet
@moopet - 我甚至不认为'wsgi.py'文件被调用时,如何使gunicorn挑选文件? –