summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-13 19:31:18 -0600
committerDan McGee <dan@archlinux.org>2013-01-13 19:31:18 -0600
commitc1c12b353851a164777dc7d0fa79d3509f7f0e0e (patch)
tree3e135b8e09f82d2cb2d171db9b3017a6ae5a88d7
parent9234d7787757a712f63d590748897f31d72ac61e (diff)
Enable newrelic in WSGI if available
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--archweb.wsgi21
1 files changed, 19 insertions, 2 deletions
diff --git a/archweb.wsgi b/archweb.wsgi
index abe5419a..6fac21e9 100644
--- a/archweb.wsgi
+++ b/archweb.wsgi
@@ -3,12 +3,29 @@ 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, "/srv/http/archweb")
+sys.path.insert(0, base_path)
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
-os.chdir("/srv/http/archweb")
+os.chdir(base_path)
+
+using_newrelic = False
+try:
+ 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 = application = newrelic.agent.wsgi_application()(application)