Пример #1
0
        def inner_run() -> None:
            from django.conf import settings
            from django.utils import translation

            translation.activate(settings.LANGUAGE_CODE)

            # We pass display_num_errors=False, since Django will
            # likely display similar output anyway.
            self.check(display_num_errors=False)
            print(f"Tornado server (re)started on port {port}")

            if settings.USING_RABBITMQ:
                queue_client = get_queue_client()
                assert isinstance(queue_client, TornadoQueueClient)
                # Process notifications received via RabbitMQ
                queue_name = notify_tornado_queue_name(port)
                queue_client.start_json_consumer(
                    queue_name, get_wrapped_process_notification(queue_name)
                )

            try:
                # Application is an instance of Django's standard wsgi handler.
                application = create_tornado_application()
                if settings.AUTORELOAD:
                    zulip_autoreload_start()

                # start tornado web server in single-threaded mode
                http_server = httpserver.HTTPServer(
                    application, xheaders=xheaders, no_keep_alive=no_keep_alive
                )
                http_server.listen(port, address=addr)

                from zerver.tornado.ioloop_logging import logging_data

                logging_data["port"] = str(port)
                setup_event_queue(port)
                add_client_gc_hook(missedmessage_hook)
                setup_tornado_rabbitmq()

                instance = ioloop.IOLoop.instance()

                if django.conf.settings.DEBUG:
                    instance.set_blocking_log_threshold(5)
                    instance.handle_callback_exception = handle_callback_exception
                instance.start()
            except KeyboardInterrupt:
                sys.exit(0)
Пример #2
0
        def inner_run() -> None:
            from django.conf import settings
            from django.utils import translation
            translation.activate(settings.LANGUAGE_CODE)

            print("Validating Django models.py...")
            self.check(display_num_errors=True)
            print("\nDjango version %s" % (django.get_version(), ))
            print("Tornado server is running at http://%s:%s/" % (addr, port))
            print("Quit the server with %s." % (quit_command, ))

            if settings.USING_RABBITMQ:
                queue_client = get_queue_client()
                # Process notifications received via RabbitMQ
                queue_client.register_json_consumer(
                    notify_tornado_queue_name(int(port)), process_notification)
                queue_client.register_json_consumer(
                    tornado_return_queue_name(int(port)), respond_send_message)

            try:
                # Application is an instance of Django's standard wsgi handler.
                application = create_tornado_application(int(port))
                if settings.AUTORELOAD:
                    zulip_autoreload_start()

                # start tornado web server in single-threaded mode
                http_server = httpserver.HTTPServer(
                    application,
                    xheaders=xheaders,
                    no_keep_alive=no_keep_alive)
                http_server.listen(int(port), address=addr)

                setup_event_queue(int(port))
                add_client_gc_hook(missedmessage_hook)
                setup_tornado_rabbitmq()
                from zerver.tornado.ioloop_logging import logging_data
                logging_data['port'] = port

                instance = ioloop.IOLoop.instance()

                if django.conf.settings.DEBUG:
                    instance.set_blocking_log_threshold(5)
                    instance.handle_callback_exception = handle_callback_exception
                instance.start()
            except KeyboardInterrupt:
                sys.exit(0)
Пример #3
0
        def inner_run() -> None:
            from django.conf import settings
            from django.utils import translation
            translation.activate(settings.LANGUAGE_CODE)

            print("Validating Django models.py...")
            self.check(display_num_errors=True)
            print("\nDjango version %s" % (django.get_version()))
            print("Tornado server is running at http://%s:%s/" % (addr, port))
            print("Quit the server with %s." % (quit_command,))

            if settings.USING_RABBITMQ:
                queue_client = get_queue_client()
                # Process notifications received via RabbitMQ
                queue_client.register_json_consumer(notify_tornado_queue_name(int(port)),
                                                    process_notification)
                queue_client.register_json_consumer(tornado_return_queue_name(int(port)),
                                                    respond_send_message)

            try:
                # Application is an instance of Django's standard wsgi handler.
                application = create_tornado_application(int(port))
                if settings.AUTORELOAD:
                    zulip_autoreload_start()

                # start tornado web server in single-threaded mode
                http_server = httpserver.HTTPServer(application,
                                                    xheaders=xheaders,
                                                    no_keep_alive=no_keep_alive)
                http_server.listen(int(port), address=addr)

                setup_event_queue(int(port))
                add_client_gc_hook(missedmessage_hook)
                setup_tornado_rabbitmq()
                from zerver.tornado.ioloop_logging import logging_data
                logging_data['port'] = port

                instance = ioloop.IOLoop.instance()

                if django.conf.settings.DEBUG:
                    instance.set_blocking_log_threshold(5)
                    instance.handle_callback_exception = handle_callback_exception
                instance.start()
            except KeyboardInterrupt:
                sys.exit(0)