Created
November 8, 2012 19:57
-
-
Save whardier/4041139 to your computer and use it in GitHub Desktop.
HollaBackYo Broken ToRELPServer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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