예제 #1
0
        def inner_run():
            from django.conf import settings
            from django.utils import translation
            print "Validating models..."
            self.validate(display_num_errors=True)
            print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
            print "Socket Server is running at http://%s:%s/" % (addr, port)
            print "Quit the server with %s." % quit_command

            # django.core.management.base forces the locate to en-us. We
            # should set it up correctly for the first request
            # (particularly important in the not "--reload" case).
            translation.activate(settings.LANGUAGE_CODE)
            
            try:
                # Instance Django's wsgi handler.
                application = web.Application(
                    [ ChatRouter.route()],
                    enabled_protocols = ['websocket',
                                        'flashsocket',
                                        'xhr-multipart',
                                        'xhr-polling'],
                    flash_policy_port = 8843,
                    flash_policy_file = flash_policy_file,
                    socket_io_port = port
                )
                # start tornado web server in single-threaded mode
                # instead auto pre-fork mode with bind/start.
                tornadio.server.SocketServer(application)

            except KeyboardInterrupt:
                if shutdown_message:
                    print shutdown_message
                sys.exit(0)
예제 #2
0
from chatroom.view import ChatRouter

ROUTS =  [ ChatRouter.route(),]