channels配置支持redis
parent
e98032200e
commit
ace197d5a8
|
@ -170,19 +170,22 @@ CORS_ALLOW_CREDENTIALS = True # 指明在跨域访问中,后端是否支持
|
||||||
# ********************* channels配置 ******************* #
|
# ********************* channels配置 ******************* #
|
||||||
# ================================================= #
|
# ================================================= #
|
||||||
ASGI_APPLICATION = 'application.asgi.application'
|
ASGI_APPLICATION = 'application.asgi.application'
|
||||||
# CHANNEL_LAYERS = {
|
if not locals().get('REDIS_HOST', ""):
|
||||||
# "default": {
|
CHANNEL_LAYERS = {
|
||||||
# "BACKEND": "channels.layers.InMemoryChannelLayer"
|
"default": {
|
||||||
# }
|
"BACKEND": "channels.layers.InMemoryChannelLayer"
|
||||||
# }
|
}
|
||||||
CHANNEL_LAYERS = {
|
}
|
||||||
'default': {
|
else:
|
||||||
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
REDIS_URL = locals().get('REDIS_URL', "")
|
||||||
'CONFIG': {
|
CHANNEL_LAYERS = {
|
||||||
"hosts": [('127.0.0.1', 6379)], #需修改
|
'default': {
|
||||||
|
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
||||||
|
'CONFIG': {
|
||||||
|
"hosts": [(REDIS_URL)], # 需修改
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# ================================================= #
|
# ================================================= #
|
||||||
|
|
Loading…
Reference in New Issue