mirror of
https://github.com/django/daphne.git
synced 2024-11-25 17:23:43 +03:00
build_endpoint_description_string is now a normal function
This commit is contained in:
parent
76b441ecdf
commit
5ea0749c5f
|
@ -2,7 +2,7 @@ import sys
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import importlib
|
import importlib
|
||||||
from .server import Server
|
from .server import Server, build_endpoint_description_strings
|
||||||
from .access import AccessLogGenerator
|
from .access import AccessLogGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,19 +165,24 @@ class CommandLineInterface(object):
|
||||||
elif args.port and not args.host:
|
elif args.port and not args.host:
|
||||||
args.host = DEFAULT_HOST
|
args.host = DEFAULT_HOST
|
||||||
|
|
||||||
# Run server
|
# build endpoint description strings from (optional) cli arguments
|
||||||
logger.info(
|
endpoints = build_endpoint_description_strings(
|
||||||
"Starting server at %s, channel layer %s",
|
|
||||||
(args.unix_socket if args.unix_socket else "%s:%s" % (args.host, args.port)),
|
|
||||||
args.channel_layer,
|
|
||||||
)
|
|
||||||
self.server = Server(
|
|
||||||
channel_layer=channel_layer,
|
|
||||||
host=args.host,
|
host=args.host,
|
||||||
port=args.port,
|
port=args.port,
|
||||||
unix_socket=args.unix_socket,
|
unix_socket=args.unix_socket,
|
||||||
file_descriptor=args.file_descriptor,
|
file_descriptor=args.file_descriptor
|
||||||
endpoints=args.socket_strings,
|
)
|
||||||
|
endpoints = sorted(
|
||||||
|
args.socket_strings + endpoints
|
||||||
|
)
|
||||||
|
logger.info(
|
||||||
|
'Starting server at %s, channel layer %s.' %
|
||||||
|
(endpoints.join(', '), args.channel_layer)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.server = Server(
|
||||||
|
channel_layer=channel_layer,
|
||||||
|
endpoints=endpoints,
|
||||||
http_timeout=args.http_timeout,
|
http_timeout=args.http_timeout,
|
||||||
ping_interval=args.ping_interval,
|
ping_interval=args.ping_interval,
|
||||||
ping_timeout=args.ping_timeout,
|
ping_timeout=args.ping_timeout,
|
||||||
|
|
|
@ -33,8 +33,14 @@ class Server(object):
|
||||||
verbosity=1
|
verbosity=1
|
||||||
):
|
):
|
||||||
self.channel_layer = channel_layer
|
self.channel_layer = channel_layer
|
||||||
|
self.endpoints = endpoints
|
||||||
|
|
||||||
self.endpoints = sorted(endpoints + self.build_endpoint_description_strings(
|
if any([host, port, unix_socket, file_descriptor]):
|
||||||
|
raise DeprecationWarning('''
|
||||||
|
The host/port/unix_socket/file_descriptor keyword arguments to %s are deprecated.
|
||||||
|
''' % self.__class__.__name__)
|
||||||
|
# build endpoint description strings from deprecated kwargs
|
||||||
|
self.endpoints = sorted(self.endpoints + build_endpoint_description_strings(
|
||||||
host=host,
|
host=host,
|
||||||
port=port,
|
port=port,
|
||||||
unix_socket=unix_socket,
|
unix_socket=unix_socket,
|
||||||
|
@ -163,7 +169,7 @@ class Server(object):
|
||||||
self.factory.check_timeouts()
|
self.factory.check_timeouts()
|
||||||
reactor.callLater(2, self.timeout_checker)
|
reactor.callLater(2, self.timeout_checker)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def build_endpoint_description_strings(
|
def build_endpoint_description_strings(
|
||||||
host=None,
|
host=None,
|
||||||
port=None,
|
port=None,
|
||||||
|
@ -171,7 +177,9 @@ class Server(object):
|
||||||
file_descriptor=None
|
file_descriptor=None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Build a list of twisted endpoint description strings that the server will listen on
|
Build a list of twisted endpoint description strings that the server will listen on.
|
||||||
|
This is to streamline the generation of twisted endpoint description strings from easier
|
||||||
|
to use command line args such as host, port, unix sockets etc.
|
||||||
"""
|
"""
|
||||||
socket_descriptions = []
|
socket_descriptions = []
|
||||||
if host and port:
|
if host and port:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user