mirror of
https://github.com/django/daphne.git
synced 2025-07-25 14:39:46 +03:00
Added support for specifying the number of worker processes in the CLI and runserver command.
This commit is contained in:
parent
064ca7a567
commit
663cf4a23d
|
@ -160,6 +160,13 @@ class CommandLineInterface:
|
|||
self.parser.add_argument(
|
||||
"--no-server-name", dest="server_name", action="store_const", const=""
|
||||
)
|
||||
self.parser.add_argument(
|
||||
"-w",
|
||||
"--workers",
|
||||
type=int,
|
||||
help="Number of worker processes to spawn",
|
||||
default=1,
|
||||
)
|
||||
|
||||
self.server = None
|
||||
|
||||
|
@ -287,5 +294,6 @@ class CommandLineInterface:
|
|||
"X-Forwarded-Proto" if args.proxy_headers else None
|
||||
),
|
||||
server_name=args.server_name,
|
||||
workers=args.workers,
|
||||
)
|
||||
self.server.run()
|
||||
|
|
|
@ -85,6 +85,14 @@ class Command(RunserverCommand):
|
|||
dest="insecure_serving",
|
||||
help="Allows serving static files even if DEBUG is False.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--workers",
|
||||
action="store",
|
||||
dest="workers",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Number of worker processes to spawn (default: 1)",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.http_timeout = options.get("http_timeout", None)
|
||||
|
@ -144,6 +152,7 @@ class Command(RunserverCommand):
|
|||
http_timeout=self.http_timeout,
|
||||
root_path=getattr(settings, "FORCE_SCRIPT_NAME", "") or "",
|
||||
websocket_handshake_timeout=self.websocket_handshake_timeout,
|
||||
workers=options["workers"],
|
||||
).run()
|
||||
logger.debug("Daphne exited")
|
||||
except KeyboardInterrupt:
|
||||
|
|
Loading…
Reference in New Issue
Block a user