Skip to content

Instantly share code, notes, and snippets.

@deniszh
Created February 24, 2016 22:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deniszh/ba79af2728f8ba23afcb to your computer and use it in GitHub Desktop.
Save deniszh/ba79af2728f8ba23afcb to your computer and use it in GitHub Desktop.
mport os
import sys
sys.path.append('/opt/graphite/webapp')
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
from graphite.logger import log
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 = "/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)
# Initializing the search index can be very expensive. The import below
# ensures the index is preloaded before any requests are handed to the
# process.
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search # noqa
@kennedyoliveira
Copy link

It's missing the i in mport os from the first line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment