summaryrefslogtreecommitdiff
path: root/archweb.wsgi
blob: f8de2b49891d378e924e2b95be7b839a00a023d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
import os
import sys
import site

base_path = "/srv/http/archweb"

site.addsitedir('/srv/http/archweb-env/lib/python2.7/site-packages')
sys.path.insert(0, base_path)

os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

os.chdir(base_path)

using_newrelic = False
try:
    key_path = os.path.join(base_path, "newrelic.key")
    if os.path.exists(key_path):
        with open(key_path) as keyfile:
            key = keyfile.read().strip()
        os.environ["NEW_RELIC_LICENSE_KEY"] = key

    import newrelic.agent
    from newrelic.api.exceptions import ConfigurationError
    try:
        newrelic.agent.initialize(os.path.join(base_path, "newrelic.ini"))
        using_newrelic = True
    except ConfigurationError:
        pass
except ImportError:
    pass

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

if using_newrelic:
    application = newrelic.agent.wsgi_application()(application)