Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat May 24, 2014 1:16 pm 
Offline
Newbie

Joined: Sat May 24, 2014 1:12 pm
Posts: 2
I've used New Relic in the past for PHP projects, but I am now trying to use it on a new server for a Python project. The extent of my linux server administration experience is I was able to follow this tutorial to setup the server and get everything working for uWSGI: https://library.linode.com/web-servers/ ... e-pangolin

However, I am struggling to setup New Relic's uWSGI integration using their documentation (https://docs.newrelic.com/docs/python/p ... -and-uwsgi). Their instructions point to configuration and startup files that I didn't have to modify (thanks to the great linode documentation), so I'm not really sure where to go from here or what to do next.

Has anyone else use New Relic with uWSGI and can point me in the right direction?


Top
   
PostPosted: Mon May 26, 2014 4:37 am 
Offline
Senior Member

Joined: Fri Jul 03, 2009 2:31 am
Posts: 54
ICQ: 897607
I use uWSGI with New Relic. I don't use their wrapper script or anything like that, just the wsgi_application wrapper function. So, I do something like this in my wsgi.py module:

Code:
from django.core.wsgi import get_wsgi_application

newrelic_ini = 'path/to/newrelic.ini'

try:
    import newrelic.agent
except:
    application = get_wsgi_application()
else:
    newrelic.agent.initialize(newrelic_ini, 'production')
    @newrelic.agent.wsgi_application()
    def application(environ, start_response):
        _application = get_wsgi_application()
        return _application(environ, start_response)


I do the try/except thing so that I can use the same wsgi.py on dev machines without New Relic.


Top
   
PostPosted: Mon Jul 07, 2014 3:00 pm 
Offline
Newbie

Joined: Sat May 24, 2014 1:12 pm
Posts: 2
Thanks, worked like a charm!
I'm using Bottlepy as my web app framework, so I just needed to do the following:

Code:
newrelic_ini = '/newrelic.ini'

try:
    import newrelic.agent

    newrelic.agent.initialize(newrelic_ini, 'production')

    application = newrelic.agent.WSGIApplicationWrapper(bottle.default_app())

except:
    print 'newrelic agent not found... continuing anyways'
    application = bottle.default_app()




Note: I had to follow the instructions here (http://www.julianbez.com/blog/2013/07/2 ... -pangolin/) in order to get the latest version of uWSGI in order for the New Relic Python Agent to work. apt-get only gives you version 1.0.3 which is not supported. I then had to update my .xml config file in the /etc/uwsgi/apps-available directory to replace deprecated config options:

Replaced
Code:
<app mountpoint="/">
        <script>wsgi_configuration_module</script>
</app>

with

Code:
<module>wsgi_configuration_module</module>


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group