diff --git a/channels/management/commands/runworker.py b/channels/management/commands/runworker.py index ec2b68a..81f80b9 100644 --- a/channels/management/commands/runworker.py +++ b/channels/management/commands/runworker.py @@ -1,10 +1,12 @@ from __future__ import unicode_literals +from django.conf import settings from django.core.management import BaseCommand, CommandError from channels import DEFAULT_CHANNEL_LAYER, channel_layers from channels.log import setup_logger from channels.worker import Worker +from channels.staticfiles import StaticFilesConsumer class Command(BaseCommand): @@ -38,7 +40,11 @@ class Command(BaseCommand): "Change your settings to use a cross-process channel layer." ) # Check a handler is registered for http reqs - self.channel_layer.router.check_default() + # Serve static files if Django in debug mode + if settings.DEBUG: + self.channel_layer.router.check_default(http_consumer=StaticFilesConsumer()) + else: + self.channel_layer.router.check_default() # Launch a worker self.logger.info("Running worker against channel layer %s", self.channel_layer) # Optionally provide an output callback diff --git a/docs/getting-started.rst b/docs/getting-started.rst index efd51ac..20b42c1 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -320,6 +320,7 @@ As you can probably guess, this disables the worker threads in ``runserver`` and handles them in a separate process. You can pass ``-v 2`` to ``runworker`` if you want to see logging as it runs the consumers. +If Django in debug mode(`DEBUG=True`), it'll serve static files as Django default behavior. Persisting Data ---------------