Example #1
0
    def inner_run(self):
        """Get handler and start IOLoop"""
        parse_command_line()
        logger.info("Validating models...")
        self.validate(display_num_errors=True)
        logger.info("\nDjango version %(version)s, using settings %(settings)r\n"
                   "Server is running at http://%(addr)s:%(port)s/\n"
                   "Quit the server with %(quit_command)s.\n" % {
                       "version": self.get_version(),
                       "settings": settings.SETTINGS_MODULE,
                       "addr": self.addr,
                       "port": self.port,
                       "quit_command": self.quit_command,
                   })

        app = self.get_handler()
        set_application(app)

        server = httpserver.HTTPServer(app)
        server.listen(int(self.port), address=self.addr)
        try:
            ioloop.IOLoop.instance().start()
        except KeyboardInterrupt:
            logger.warn("Shutting down Tornado ...")
        finally:
            tornado_exit.send_robust(sender=self)
            sys.exit(0)
Example #2
0
    def __init__(self, handlers, io_loop=None):

        application = DjangoApplication(get_named_urlspecs(handlers))
        io_loop = io_loop or ioloop.IOLoop.instance()
        super(TestServer, self).__init__(application, io_loop=io_loop)
        set_application(application)