#!/usr/bin/env python

import os
import cherrypy
from cherrypy import wsgiserver
from coverart_redirect.server import make_application
from coverart_redirect.config import Config

config_path = os.path.dirname(os.path.abspath(__file__)) + '/coverart_redirect.conf'
static_path = os.path.dirname(os.path.abspath(__file__)) + '/static'

config = Config(config_path, static_path)
application = make_application(config)

server = wsgiserver.CherryPyWSGIServer((config.listen.addr, int(config.listen.port)), 
                                       application)
cherrypy.config.update({ 
    'log.screen': True,
    "server.thread_pool" : 10
})
cherrypy.log("server starting")
try:
    server.start()
except KeyboardInterrupt:
    server.stop()

@@ -37,48 +37,11 @@
 ort 
-cherrypy%0Afrom cherrypy import wsgiserver
+sys
 %0Afro
@@ -136,16 +136,955 @@
 Config%0A%0A
+%0Adef production (addr, port, application):%0A    import cherrypy%0A    from cherrypy import wsgiserver%0A%0A    server = wsgiserver.CherryPyWSGIServer((addr, port), application)%0A%0A    cherrypy.config.update(%7B%0A            'log.screen': True,%0A            %22server.thread_pool%22 : 10%0A    %7D)%0A    cherrypy.log(%22server starting%22)%0A%0A    try:%0A        server.start()%0A    except KeyboardInterrupt:%0A        server.stop()%0A%0A%0Adef development (addr, port, application):%0A    from werkzeug import run_simple%0A%0A    run_simple (addr, port, application, use_reloader=True,%0A                extra_files=None, reloader_interval=1, threaded=False,%0A                processes=1, request_handler=None)%0A%0A%0Adef help ():%0A    print %22%22%22%0Asyntax: python coverart_redirect_server.py %5Boptions%5D%0A%0Aoptions:%0A%0A    --help               This message%0A    -r, --development    Use werkzeug development server (restarts on source code changes)%0A%0A%22%22%22%0A    sys.exit (0)%0A%0A%0Aif __name__ == '__main__':%0A    
 config_p
@@ -1160,16 +1160,20 @@
 t.conf'%0A
+    
 static_p
@@ -1234,16 +1234,20 @@
 tatic'%0A%0A
+    
 config =
@@ -1280,16 +1280,20 @@
 c_path)%0A
+    
 applicat
@@ -1328,48 +1328,19 @@
 g)%0A%0A
-server = wsgiserver.CherryPyWSGIServer((
+    addr = 
 conf
@@ -1353,17 +1353,27 @@
 ten.addr
-,
+%0A    port =
  int(con
@@ -1392,243 +1392,242 @@
 ort)
-), %0A                                       application)%0Acherrypy.config.update(%7B %0A    'log.scre
+%0A%0A    if len (sys.argv) %3C 2 or sys.argv%5B1%5D == '--help':%0A        help ()%0A    elif sys.argv%5B1%5D == '-r' or sys.argv%5B1%5D == '--developm
 en
+t
 ':
- True,%0A    %22server.thread_pool%22 : 10%0A%7D)%0Acherrypy.log(%22server starting%22)%0Atry:%0A    server.start()%0Aexcept KeyboardInterrupt:%0A    server.stop(
+%0A        development (addr, port, application)%0A    else:%0A        production (addr, port, application
 )%0A
+%0A

Add wsgi development server.