I had a running instance of Graphite-Web 0.9.15, due to recent bug fixes and general slowness when loading data with Grafana I decided I should probably try and upgrade Graphite.
I went on and git cloned
all the repositories and then ran python setup.py install
to the default location, the config files stayed where they were, I didn't merge.
When I tried to run the uwsgi
app again I got the following error:
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
I'm not sure running pip install
will do the trick since PyPI only has the 0.9.15 version.
What I need is to find a way to make this django
instance recognise the graphite.settings
module.
I did manage to import graphite.settings
module when runnning python
externally at some point, now it's not working either.
/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
Command:
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
Running the internal command outside the /etc/init.d/uwsgi
script yields:
[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]
And this is where the error might be coming from: /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)
Anything else I can add?
Thanks!
Instead of cloning and installing yourself you could try installing the latest commit via pip as explained here: https://stackoverflow.com/a/20101940/621690 (and further https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support)
pip install git+https://github.com/graphite-project/graphite-web.git
(add @<hash/branch-spec>
to checkout a certain state)