mirror of
https://github.com/django/daphne.git
synced 2024-11-22 07:56:34 +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 logging
|
||||
import importlib
|
||||
from .server import Server
|
||||
from .server import Server, build_endpoint_description_strings
|
||||
from .access import AccessLogGenerator
|
||||
|
||||
|
||||
|
@ -165,19 +165,24 @@ class CommandLineInterface(object):
|
|||
elif args.port and not args.host:
|
||||
args.host = DEFAULT_HOST
|
||||
|
||||
# Run server
|
||||
logger.info(
|
||||
"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,
|
||||
# build endpoint description strings from (optional) cli arguments
|
||||
endpoints = build_endpoint_description_strings(
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
unix_socket=args.unix_socket,
|
||||
file_descriptor=args.file_descriptor,
|
||||
endpoints=args.socket_strings,
|
||||
file_descriptor=args.file_descriptor
|
||||
)
|
||||
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,
|
||||
ping_interval=args.ping_interval,
|
||||
ping_timeout=args.ping_timeout,
|
||||
|
|
|
@ -33,8 +33,14 @@ class Server(object):
|
|||
verbosity=1
|
||||
):
|
||||
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,
|
||||
port=port,
|
||||
unix_socket=unix_socket,
|
||||
|
@ -163,7 +169,7 @@ class Server(object):
|
|||
self.factory.check_timeouts()
|
||||
reactor.callLater(2, self.timeout_checker)
|
||||
|
||||
@staticmethod
|
||||
|
||||
def build_endpoint_description_strings(
|
||||
host=None,
|
||||
port=None,
|
||||
|
@ -171,7 +177,9 @@ class Server(object):
|
|||
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 = []
|
||||
if host and port:
|
||||
|
|
Loading…
Reference in New Issue
Block a user