Skip to content

Commit

Permalink
Add newrelic (#416)
Browse files Browse the repository at this point in the history
* add newrelic

* small cleanup
  • Loading branch information
BernhardPosselt committed Jan 5, 2017
1 parent 2278d49 commit 08c1a6c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -22,3 +22,4 @@ bin/
*.swp
*.log
*.mo
newrelic.ini
4 changes: 4 additions & 0 deletions docs/installation.rst
Expand Up @@ -427,3 +427,7 @@ and reload apache::
sudo chown -R $(whoami):users /var/www
bash scripts/maintenance/update.sh apache
sudo chown -R www-data:www-data /var/www
Monitoring
~~~~~~~~~~
By default monitoring the application via New Relic is supported by simply placing a file called **newrelic.ini** into the base folder (the folder that also contains the **manage.py** file).
14 changes: 14 additions & 0 deletions nextcloudappstore/wsgi.py
Expand Up @@ -8,10 +8,24 @@
"""

import os
from os.path import pardir, join, dirname, abspath, realpath, isfile

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'nextcloudappstore.settings.production')

application = get_wsgi_application()


def find_in_root(path):
return join(realpath(join(dirname(abspath(__file__)), pardir)), path)


# if a new relic config file is present enable it
relic_conf = find_in_root('newrelic.ini')

if isfile(relic_conf):
import newrelic.agent
newrelic.agent.initialize(relic_conf)
application = newrelic.agent.WSGIApplicationWrapper(application)
1 change: 1 addition & 0 deletions requirements/production.txt
@@ -1,2 +1,3 @@
gunicorn==19.6.0
newrelic==2.78.0.57

0 comments on commit 08c1a6c

Please sign in to comment.