mirror of
https://github.com/django/daphne.git
synced 2025-04-21 17:22:03 +03:00
Make test project useable in a production load testing setting
This commit is contained in:
parent
bea5b138ef
commit
b3c101bd79
19
testproject/Dockerfile
Normal file
19
testproject/Dockerfile
Normal file
|
@ -0,0 +1,19 @@
|
|||
FROM ubuntu:16.04
|
||||
|
||||
MAINTAINER Andrew Godwin <andrew@aeracode.org>
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
git \
|
||||
python-dev \
|
||||
python-setuptools \
|
||||
python-pip && \
|
||||
pip install -U pip
|
||||
|
||||
RUN pip install channels==0.9.5 asgi_redis==0.8.3
|
||||
|
||||
RUN git clone https://github.com/andrewgodwin/channels.git /srv/application/
|
||||
|
||||
WORKDIR /srv/application/testproject/
|
||||
|
||||
EXPOSE 80
|
18
testproject/docker-compose.yml
Normal file
18
testproject/docker-compose.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
version: '2'
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
daphne:
|
||||
image: channels-test
|
||||
build: .
|
||||
command: daphne -b 0.0.0.0 -p 80 testproject.asgi:channel_layer
|
||||
ports:
|
||||
- "80:80"
|
||||
depends_on:
|
||||
- redis
|
||||
worker:
|
||||
image: channels-test
|
||||
build: .
|
||||
command: python manage.py runworker
|
||||
depends_on:
|
||||
- redis
|
6
testproject/testproject/asgi.py
Normal file
6
testproject/testproject/asgi.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
import os
|
||||
from channels.asgi import get_channel_layer
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
|
||||
|
||||
channel_layer = get_channel_layer()
|
|
@ -29,10 +29,10 @@ DATABASES = {
|
|||
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "asgiref.inmemory.ChannelLayer",
|
||||
"BACKEND": "asgi_redis.RedisChannelLayer",
|
||||
"ROUTING": "testproject.urls.channel_routing",
|
||||
"CONFIG": {
|
||||
"hosts": [os.environ.get('REDIS_URL', 'redis://redis:6379')],
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
if os.environ.get("USEREDIS", None):
|
||||
CHANNEL_BACKENDS['default']['BACKEND'] = "asgi_redis.RedisChannelLayer"
|
||||
|
|
Loading…
Reference in New Issue
Block a user