Graphite和GUnicorn - 配置问题还是路径问题
我一直在尝试通过GUnicorn来运行Graphite,最后再通过nginx进行代理。不过我几乎尝试了所有方法来启动这个应用,但总是遇到类似下面的错误,无法解决。
(graphite)/opt/graphite/conf gunicorn --bind=127.0.0.1:8080 graphite.wsgi:app
2014-03-03 17:02:14 [312] [INFO] Starting gunicorn 18.0
2014-03-03 17:02:14 [312] [INFO] Listening at: http://127.0.0.1:8080 (312)
2014-03-03 17:02:14 [312] [INFO] Using worker: sync
2014-03-03 17:02:14 [317] [INFO] Booting worker with pid: 317
2014-03-03 17:02:14 [317] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
return self.load_wsgiapp()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
__import__(module)
ImportError: No module named graphite.wsgi
Traceback (most recent call last):
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
return self.load_wsgiapp()
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/graphite/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
__import__(module)
ImportError: No module named graphite.wsgi
2014-03-03 17:02:14 [317] [INFO] Worker exiting (pid: 317)
2014-03-03 17:02:14 [312] [INFO] Shutting down: Master
2014-03-03 17:02:14 [312] [INFO] Reason: Worker failed to boot.
我尝试在不同的目录下运行(根目录、配置目录、网页应用目录等等)。我还试过用gunicorn_django这个助手来运行。我可以使用开发服务器启动它:opt/graphite/bin/run-graphite-devel-server.py --port=8080 /opt/graphite
我通过virtualenv和pip安装了所有东西,并且简单地把graphite.wsgi.example文件复制成了graphite.wsgi,放在conf
目录下。看起来是这样的:
(graphite)/opt/graphite/conf cat graphite.wsgi.example
import os, sys
sys.path.append('/opt/graphite/webapp')
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
# READ THIS
# Initializing the search index can be very expensive, please include
# the WSGIImportScript directive pointing to this script in your vhost
# config to ensure the index is preloaded before any requests are handed
# to the process.
from graphite.logger import log
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search
(graphite)/opt/graphite/conf
如果能得到任何帮助,我将非常感激。
1 个回答
7
这肯定不是正确的方法,但我也遇到过同样的问题,我是这样解决的:
mv /opt/graphite/conf/graphite.wsgi.example /opt/graphite/webapp/graphite/graphite_wsgi.py
cd /opt/graphite/webapp/graphite
gunicorn graphite_wsgi:application
你的问题可能只是用错了'app'这个词,应该用'应用'这个变量,试试看吧。
祝你好运!