diff --git a/daphne/cli.py b/daphne/cli.py index e6e79b2..c700993 100755 --- a/daphne/cli.py +++ b/daphne/cli.py @@ -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() diff --git a/daphne/management/commands/runserver.py b/daphne/management/commands/runserver.py index 7e67e07..af7e8f4 100644 --- a/daphne/management/commands/runserver.py +++ b/daphne/management/commands/runserver.py @@ -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: