Exemplo n.º 1
0
 def handle(self, *args, **options):
     # Get the backend to use
     channel_backend = channel_backends[DEFAULT_CHANNEL_BACKEND]
     auto_import_consumers()
     if channel_backend.local_only:
         raise CommandError(
             "You have a process-local channel backend configured, and so cannot run separate interface servers.\n"
             "Configure a network-based backend in CHANNEL_BACKENDS to use this command."
         )
     # Run the interface
     port = options.get("port", None) or 9000
     self.stdout.write("Running Twisted/Autobahn WebSocket interface server")
     self.stdout.write(" Channel backend: %s" % channel_backend)
     self.stdout.write(" Listening on: ws://0.0.0.0:%i" % port)
     WebsocketTwistedInterface(channel_backend=channel_backend, port=port).run()
Exemplo n.º 2
0
 def run(self, *args, **options):
     # Force disable reloader for now
     options['use_reloader'] = False
     # Check a handler is registered for http reqs
     self.channel_backend = channel_backends[DEFAULT_CHANNEL_BACKEND]
     auto_import_consumers()
     if not self.channel_backend.registry.consumer_for_channel("django.wsgi.request"):
         # Register the default one
         self.channel_backend.registry.add_consumer(UrlConsumer(), ["django.wsgi.request"])
     # Launch a worker thread
     worker = WorkerThread(self.channel_backend)
     worker.daemon = True
     worker.start()
     # Run the rest
     return super(Command, self).run(*args, **options)
Exemplo n.º 3
0
 def run(self, *args, **options):
     # Force disable reloader for now
     options['use_reloader'] = False
     # Check a handler is registered for http reqs
     self.channel_backend = channel_backends[DEFAULT_CHANNEL_BACKEND]
     auto_import_consumers()
     if not self.channel_backend.registry.consumer_for_channel(
             "django.wsgi.request"):
         # Register the default one
         self.channel_backend.registry.add_consumer(UrlConsumer(),
                                                    ["django.wsgi.request"])
     # Launch a worker thread
     worker = WorkerThread(self.channel_backend)
     worker.daemon = True
     worker.start()
     # Run the rest
     return super(Command, self).run(*args, **options)
Exemplo n.º 4
0
 def handle(self, *args, **options):
     # Get the backend to use
     channel_backend = channel_backends[DEFAULT_CHANNEL_BACKEND]
     auto_import_consumers()
     if channel_backend.local_only:
         raise CommandError(
             "You have a process-local channel backend configured, and so cannot run separate interface servers.\n"
             "Configure a network-based backend in CHANNEL_BACKENDS to use this command."
         )
     # Run the interface
     port = options.get("port", None) or 9000
     self.stdout.write(
         "Running Twisted/Autobahn WebSocket interface server")
     self.stdout.write(" Channel backend: %s" % channel_backend)
     self.stdout.write(" Listening on: ws://0.0.0.0:%i" % port)
     WebsocketTwistedInterface(channel_backend=channel_backend,
                               port=port).run()
Exemplo n.º 5
0
 def handle(self, *args, **options):
     # Get the backend to use
     channel_backend = channel_backends[DEFAULT_CHANNEL_BACKEND]
     auto_import_consumers()
     if channel_backend.local_only:
         raise CommandError(
             "You have a process-local channel backend configured, and so cannot run separate workers.\n"
             "Configure a network-based backend in CHANNEL_BACKENDS to use this command."
         )
     # Launch a worker
     self.stdout.write("Running worker against backend %s" % channel_backend)
     # Optionally provide an output callback
     callback = None
     if options.get("verbosity", 1) > 1:
         callback = self.consumer_called
     # Run the worker
     try:
         Worker(channel_backend=channel_backend, callback=callback).run()
     except KeyboardInterrupt:
         pass
Exemplo n.º 6
0
 def handle(self, *args, **options):
     # Get the backend to use
     channel_backend = channel_backends[DEFAULT_CHANNEL_BACKEND]
     auto_import_consumers()
     if channel_backend.local_only:
         raise CommandError(
             "You have a process-local channel backend configured, and so cannot run separate workers.\n"
             "Configure a network-based backend in CHANNEL_BACKENDS to use this command."
         )
     # Launch a worker
     self.stdout.write("Running worker against backend %s" %
                       channel_backend)
     # Optionally provide an output callback
     callback = None
     if options.get("verbosity", 1) > 1:
         callback = self.consumer_called
     # Run the worker
     try:
         Worker(channel_backend=channel_backend, callback=callback).run()
     except KeyboardInterrupt:
         pass