public
Created

HollaBackYo Broken ToRELPServer

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.