Add --alias option to runworker

This commit is contained in:
Andrew Godwin 2016-03-10 17:55:28 -08:00
parent 053850fdd6
commit 1ee7b2861c

View File

@ -8,11 +8,16 @@ from channels.worker import Worker
class Command(BaseCommand):
def add_arguments(self, parser):
super(Command, self).add_arguments(parser)
parser.add_argument('--alias', action='store', dest='alias', default=DEFAULT_CHANNEL_LAYER,
help='Channel layer alias to use, if not the default.')
def handle(self, *args, **options):
# Get the backend to use
self.verbosity = options.get("verbosity", 1)
self.logger = setup_logger('django.channels', self.verbosity)
self.channel_layer = channel_layers[DEFAULT_CHANNEL_LAYER]
self.channel_layer = channel_layers[options.get("alias", DEFAULT_CHANNEL_LAYER)]
# Check that handler isn't inmemory
if self.channel_layer.local_only():
raise CommandError(