diff --git a/channels/management/commands/runserver.py b/channels/management/commands/runserver.py index 8f0dda3..9733559 100644 --- a/channels/management/commands/runserver.py +++ b/channels/management/commands/runserver.py @@ -2,7 +2,7 @@ import datetime import sys import threading -from daphne.server import Server +from daphne.server import Server, build_endpoint_description_strings from django.conf import settings from django.core.management.commands.runserver import Command as RunserverCommand from django.utils import six @@ -75,11 +75,13 @@ class Command(RunserverCommand): # Launch server in 'main' thread. Signals are disabled as it's still # actually a subthread under the autoreloader. self.logger.debug("Daphne running, listening on %s:%s", self.addr, self.port) + + # build the endpoint description string from host/port options + endpoints = build_endpoint_description_strings(host=self.addr, port=self.port) try: Server( channel_layer=self.channel_layer, - host=self.addr, - port=int(self.port), + endpoints=endpoints, signal_handlers=not options['use_reloader'], action_logger=self.log_action, http_timeout=self.http_timeout, diff --git a/channels/tests/test_management.py b/channels/tests/test_management.py index eec4e51..20d723b 100644 --- a/channels/tests/test_management.py +++ b/channels/tests/test_management.py @@ -88,12 +88,12 @@ class RunServerTests(TestCase): @mock.patch('channels.management.commands.runworker.Worker') def test_runserver_basic(self, mocked_worker, mocked_server, mock_stdout): # Django's autoreload util uses threads and this is not needed - # in the test envirionment. + # in the test environment. # See: # https://github.com/django/django/blob/master/django/core/management/commands/runserver.py#L105 call_command('runserver', '--noreload') mocked_server.assert_called_with( - port=8000, + endpoints=['tcp:port=8000:interface=127.0.0.1'], signal_handlers=True, http_timeout=60, host='127.0.0.1', @@ -114,7 +114,7 @@ class RunServerTests(TestCase): with self.settings(DEBUG=True, STATIC_URL='/static/'): call_command('runserver', '--noreload') mocked_server.assert_called_with( - port=8000, + endpoints=['tcp:port=8000:interface=127.0.0.1'], signal_handlers=True, http_timeout=60, host='127.0.0.1', @@ -126,7 +126,7 @@ class RunServerTests(TestCase): call_command('runserver', '--noreload', 'localhost:8001') mocked_server.assert_called_with( - port=8001, + endpoints=['tcp:port=8001:interface=127.0.0.1'], signal_handlers=True, http_timeout=60, host='localhost', @@ -150,7 +150,7 @@ class RunServerTests(TestCase): ''' call_command('runserver', '--noreload', '--noworker') mocked_server.assert_called_with( - port=8000, + endpoints=['tcp:port=8000:interface=127.0.0.1'], signal_handlers=True, http_timeout=60, host='127.0.0.1', diff --git a/setup.py b/setup.py index 834ff64..ca72807 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,6 @@ setup( install_requires=[ 'Django>=1.8', 'asgiref>=0.13', - 'daphne>=0.14.1', + 'daphne>=1.0.0', ] )