mirror of
https://github.com/django/daphne.git
synced 2025-07-11 00:12:18 +03:00
parent
6eaee8f522
commit
18d4cc8e6f
|
@ -1,10 +1,12 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.core.management import BaseCommand, CommandError
|
from django.core.management import BaseCommand, CommandError
|
||||||
|
|
||||||
from channels import DEFAULT_CHANNEL_LAYER, channel_layers
|
from channels import DEFAULT_CHANNEL_LAYER, channel_layers
|
||||||
from channels.log import setup_logger
|
from channels.log import setup_logger
|
||||||
from channels.worker import Worker
|
from channels.worker import Worker
|
||||||
|
from channels.staticfiles import StaticFilesConsumer
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -38,6 +40,10 @@ class Command(BaseCommand):
|
||||||
"Change your settings to use a cross-process channel layer."
|
"Change your settings to use a cross-process channel layer."
|
||||||
)
|
)
|
||||||
# Check a handler is registered for http reqs
|
# Check a handler is registered for http reqs
|
||||||
|
# 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()
|
self.channel_layer.router.check_default()
|
||||||
# Launch a worker
|
# Launch a worker
|
||||||
self.logger.info("Running worker against channel layer %s", self.channel_layer)
|
self.logger.info("Running worker against channel layer %s", self.channel_layer)
|
||||||
|
|
|
@ -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``
|
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 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
|
Persisting Data
|
||||||
---------------
|
---------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user