Skip to content

Instantly share code, notes, and snippets.

@dkdndes
Last active July 7, 2018 15:37
Show Gist options
  • Save dkdndes/581be2c0e5297aecdf5d0e7c1e639053 to your computer and use it in GitHub Desktop.
Save dkdndes/581be2c0e5297aecdf5d0e7c1e639053 to your computer and use it in GitHub Desktop.
Docker-Compose django-channels multichat example which allows scalable (async) workers
# Example for a scalable worker for Andrew Goodwins django-channels multichat example
# from https://www.excella.com/insights/scaling-django-channels-with-docker
#
# Replace the existing docker-compose.yml at
# https://github.com/andrewgodwin/channels-examples/tree/master/multichat
#
# Follow the docker-compose steps for db migration, etc. and then
#
# $ docker-compose ps
# $ docker-compose scale worker=5 &
# $ docker-compose ps
version: "2"
services:
redis:
image: redis:latest
web:
build: .
command: daphne -b 0.0.0.0 -p 8000 multichat.asgi:channel_layer
volumes:
- .:/code
ports:
- "8000:8000"
links:
- redis
worker:
build: .
command: python manage.py runworker
volumes:
- .:/code
links:
- redis
@sebastian-code
Copy link

In the web service, the command call to Daphne defines than the asgi should call a variable channel_layer, where does that variable is declared inside the ASGI configuration file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment