嗨我正在嘗試將我的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挑選文件? –