title: How to monitor this cherrypy web application with newrelic and probably convert it to wsgi
body: <p>I am running a cherrypy application using python 2.7 on windows (and using the cherrypy version from pipi). The application is running in the intranet and basically structured like the code below.</p>
  
  <p>To monitor this application with newrelic I tried to wrap it like explained in the newrelic documentation. But it did not appear in the newrelic backend when started that way, although the cherrypy application worked.</p>
  
  <p>I also tried the manual method, inserting the newrelic agent just one line after <code>def main():</code>. This made the application appear in the newrelich backend but it monitored nothing. All diagrams empty.</p>
  
  <p>I already searched the web for hours and asked some colleages without any progress.</p>
  
  <p>From the newrelic documentation I suspect I have to choose a different structure or technology in my cherrypy application. They do not use <code>quickstart</code>. So my question is how do I convert my application that it fits the newrelic way of monitoring applications.</p>
  
  <p>This is more or less the main file of the application:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  def main():
    import cherrypy
    from auth import AuthController
    from my_routes import RouteOne, RouteTwo
    dispatcher = cherrypy.dispatch.RoutesDispatcher()
    dispatcher.explicit = False
    dc = dispatcher.connect
    dc(u'd_home', u'/', RouteOne().index_home)
    dc(u'd_content', u'/content/', RouteOne().index_content)
    dc(u'd_search', u'/search/:find', RouteRoot().index_search)
    conf = { 
      '/' : {
        u'request.dispatch' : dispatcher,
        u'tools.staticdir.root' : 'c:/app/src', 
        u'tools.sessions.on' : True,
        u'tools.auth.on': True,
        u'tools.sessions.storage_type' : "file",
        u'tools.sessions.storage_path' : 'c:/app/sessions',
        u'tools.sessions.timeout' : 60,
        u'log.screen' : False,
        u'log.error_file' : 'c:/app/log/error.txt',
        u'log.access_file' : 'c:/app/log/access.txt',
        },
      u'/app/public' : {
        u'tools.staticdir.debug' : True,
        u'tools.staticdir.on' : True,
        u'tools.staticdir.dir' : u"public",
        },
    }
  
    # ... some additional initialisation left out ...
  
    cherrypy.tree.mount(None, u"/", config=conf)
    cherrypy.config.update({
      'server.socket_host': myhost.test.com,
      'server.socket_port': 8080,})
  
    from auth import check_auth
    cherrypy.tools.auth = cherrypy.Tool('before_handler', check_auth)
    cherrypy.quickstart(None, config=conf)
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>Please help me to construct in a newrelic compatible way, like wsgi, the different parts, like the config, the dispatch, the auth and the routes, so that I can monitor it.</p>
  
  <p>I am ready to do things different where necessary, I know with python almost everything is possible.</p>
  
  <p>So if this needs to be a wsgi application how do I change it? I would prefer this over other methods (like <code>paste</code>).</p>
  
  <hr>
  
  <p>I hope this can also help many other people, because I was not able to find anything specific about this and I can imagine that many cherrypy applications out there are structured similar. I spent a lot of time in the cherrypy docs but somehow was not able to put the different parts together. </p>