[3] | 1 | # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) |
---|
| 2 | # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php |
---|
| 3 | from paste.script.serve import ensure_port_cleanup |
---|
| 4 | from paste.translogger import TransLogger |
---|
| 5 | |
---|
| 6 | def run_server(wsgi_app, global_conf, host='localhost', |
---|
| 7 | port=8080): |
---|
| 8 | from wsgiutils import wsgiServer |
---|
| 9 | import logging |
---|
| 10 | logged_app = TransLogger(wsgi_app) |
---|
| 11 | port = int(port) |
---|
| 12 | # For some reason this is problematic on this server: |
---|
| 13 | ensure_port_cleanup([(host, port)], maxtries=2, sleeptime=0.5) |
---|
| 14 | app_map = {'': logged_app} |
---|
| 15 | server = wsgiServer.WSGIServer((host, port), app_map) |
---|
| 16 | logged_app.logger.info('Starting HTTP server on http://%s:%s', |
---|
| 17 | host, port) |
---|
| 18 | server.serve_forever() |
---|
| 19 | |
---|