Create a gist now

Instantly share code, notes, and snippets.

HollaBackYo Broken ToRELPServer
def serve_forever(listen_uri, mongodb_uri):
import urlparse
from pymongo import uri_parser
application = tornado.web.Application([
(r'/', MainHandler)
])
listen = urlparse.urlparse(listen_uri)
server = tornado.httpserver.HTTPServer(application)
server.bind(port=listen.port or 8888, address=listen.hostname or '')
server.start(0)
torelpserver = MyToRELPServer()
torelpserver.bind(port=20514, address='0.0.0.0')
torelpserver.start(0)
conn = motor.MotorConnection(host=mongodb_uri, document_class=MongoOrderedDict).open_sync()
mongodb = uri_parser.parse_uri(mongodb_uri, conn.port)
db = conn[mongodb['database'] or 'hollabackyo']
application.settings['conn'] = conn
application.settings['db'] = db
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment