我有一个Graphite Web0.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
模块。在
在某个时候,我确实在外部运行python
时导入了graphite.settings
模块,现在它也不工作了。在
/etc/uwsgi/apps已启用/garphite.ini公司
^{pr2}$/usr/share/uwsgi/conf/默认.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)
还有什么可以补充的吗?在
谢谢!在
要使
wsgi.py
文件正常工作,外部graphite
文件夹(包含manage.py
的文件夹,而不是包含settings.py
的内部文件夹)必须位于Python路径上。在看起来uwsgi有一个可以使用的^{} 选项,或者可以在wsgi文件中添加
sys.path.append('/path/to/graphite/)
。在您可以尝试通过pip安装最新的commit,而不是自己克隆和安装:https://stackoverflow.com/a/20101940/621690(以及进一步的https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support)
(添加
@<hash/branch-spec>
以签出某个状态)相关问题 更多 >
编程相关推荐