我有一个正在运行的Graphite-Web 0.9.15实例,由于最近的错误修复和使用Grafana加载数据时总体缓慢我决定我应该尝试升级Graphite。
我继续git cloned
所有存储库,然后将python setup.py install
运行到默认位置,配置文件保持原样,我没有合并。
当我再次尝试运行uwsgi
应用时,出现以下错误:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
self.load_middleware()
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 37, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'graphite.settings' (Is it on sys.path?): No module named graphite.settings
我不确定运行pip install
会不会起作用,因为PyPI只有0.9.15版本。
我需要找到一种方法让这个django
实例识别graphite.settings
模块。
我确实设法在某个时间从外部运行graphite.settings
时导入python
模块,现在它也无法正常工作。
/etc/uwsgi/apps-enabled/garphite.ini
plugins=python
[uwsgi]
processes = 2
socket = 127.0.0.1:3031
gid = www-data
uid = www-data
chdir = /opt/graphite/conf
module = wsgi:application
/usr/share/uwsgi/conf/default.ini
# User-made changes in this file will be silently lost, as it is silently
# rewrited with upgrade of uwsgi package.
#
# If you want to change default options of uWSGI daemon, then:
# * copy this file somewhere
# * add/remove/change options in copied file
# * edit /etc/default/uwsgi and change location of inherited configuration
# file to path to copied file
[uwsgi]
# --------------------------
# About %(deb-confnamespace)
# --------------------------
#
# uWSGI init.d script passes environment variable UWSGI_DEB_CONFNAMESPACE to
# started uWSGI daemon, which is recognized as a (fake) option with name
# 'deb-confnamespace'.
#
# 'confnamespace' means 'configuration files namespace'. Namespace is the name
# of first directory in relative path to configuration file, but with stripped
# suffix 's-enabled'. "Relative path" means "path relative to /etc/uwsgi".
#
# Example: namespace of '/etc/uwsgi/apps-enabled/site.ini' is 'app'.
# ---------------------
# About %(deb-confname)
# ---------------------
#
# uWSGI init.d script passes environment variable UWSGI_DEB_CONFNAME to
# started uWSGI daemon, which is recognized as a (fake) option with name
# 'deb-confname'.
#
# 'confname' means 'configuration name', which is a filename without
# extension of the configuration file.
#
# Example: name of '/etc/uwsgi/apps-enabled/site.ini' is 'site'.
# try to autoload appropriate plugin if "unknown" option has been specified
autoload = true
# enable master process manager
master = true
# spawn 2 uWSGI worker processes
workers = 2
# automatically kill workers on master's death
no-orphans = true
# write master's pid in file /run/uwsgi/<confnamespace>/<confname>/pid
pidfile = /run/uwsgi/%(deb-confnamespace)/%(deb-confname)/pid
# bind to UNIX socket at /run/uwsgi/<confnamespace>/<confname>/socket
socket = /run/uwsgi/%(deb-confnamespace)/%(deb-confname)/socket
# set mode of created UNIX socket
chmod-socket = 660
# place timestamps into log
log-date = true
# user identifier of uWSGI processes
uid = www-data
# group identifier of uWSGI processes
gid = www-data
命令:
start-stop-daemon --start --quiet --pidfile /run/uwsgi/app/graphite/pid --exec /usr/bin/uwsgi -- --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/graphite.ini --daemonize /var/log/uwsgi/app/graphite.log
在/etc/init.d/uwsgi
脚本之外运行内部命令会产生:
[uWSGI] getting INI configuration from /usr/share/uwsgi/conf/default.ini
[uWSGI] getting INI configuration from /etc/uwsgi/apps-enabled/graphite.ini
Tue Feb 7 07:31:23 2017 - option "module" found in plugin /usr/lib/uwsgi/plugins/python_plugin.so
Tue Feb 7 07:31:23 2017 - *** Starting uWSGI 1.2.3-debian (64bit) on [Tue Feb 7 07:31:23 2017] ***
Tue Feb 7 07:31:23 2017 - compiled with version: 4.7.2 on 06 July 2013 12:20:09
Tue Feb 7 07:31:23 2017 - detected number of CPU cores: 4
Tue Feb 7 07:31:23 2017 - current working directory: /root
Tue Feb 7 07:31:23 2017 - writing pidfile to /run/uwsgi/%(deb-confnamespace)/%(deb-confname)/pid
Tue Feb 7 07:31:23 2017 - open("/run/uwsgi/%(deb-confnamespace)/%(deb-confname)/pid"): No such file or directory [utils.c line 4196]
这就是错误可能来自的地方: 的 /opt/graphite/conf/wsgi.py
import os
import sys
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'graphite.settings') # noqa
from django.conf import settings
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
try:
import whitenoise
except ImportError:
whitenoise = False
else:
# WhiteNoise < 2.0.1 does not support Python 2.6
if sys.version_info[:2] < (2, 7):
whitenoise_version = tuple(map(
int, getattr(whitenoise, '__version__', '0').split('.')))
if whitenoise_version < (2, 0, 1):
whitenoise = False
if whitenoise:
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)
prefix = "/".join((settings.URL_PREFIX.strip('/'), 'static'))
for directory in settings.STATICFILES_DIRS:
application.add_files(directory, prefix=prefix)
for app_path in settings.INSTALLED_APPS:
module = import_module(app_path)
directory = os.path.join(os.path.dirname(module.__file__), 'static')
if os.path.isdir(directory):
application.add_files(directory, prefix=prefix)
我可以添加其他任何内容吗?
谢谢!
答案 0 :(得分:1)
通过运行以下命令可以获得相同的结果-
sudo graphite-manage migrate --run-syncdb
sudo graphite-manage migrate auth
答案 1 :(得分:0)
您可以尝试通过pip安装最新的提交,而不是克隆和自行安装,如下所示:https://stackoverflow.com/a/20101940/621690(以及https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support}
pip install git+https://github.com/graphite-project/graphite-web.git
(添加@<hash/branch-spec>
以结帐某个州)
答案 2 :(得分:0)
要使wsgi.py
文件生效,外部graphite
文件夹(包含manage.py
的文件夹,而不是包含settings.py
的内部文件夹必须位于Python上路径。
看起来uwsgi可以使用--pythonpath
选项,或者您可以在wsgi文件中添加sys.path.append('/path/to/graphite/)
。