CORRECCIÓN: arreglar excepciones silenciosas y limpiar scripts
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import re
|
||||
|
||||
with open('config/settings.py', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Replace CHANNEL_LAYERS
|
||||
old_channels = """CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [env('REDIS_URL', default='redis://localhost:6379/0')],
|
||||
},
|
||||
},
|
||||
}"""
|
||||
new_channels = """REDIS_URL = env('REDIS_URL', default=None)
|
||||
if REDIS_URL:
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [REDIS_URL],
|
||||
},
|
||||
},
|
||||
}
|
||||
else:
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels.layers.InMemoryChannelLayer"
|
||||
}
|
||||
}"""
|
||||
content = content.replace(old_channels, new_channels)
|
||||
|
||||
# Replace Celery defaults so they don't crash if REDIS_URL is None
|
||||
old_celery1 = "CELERY_BROKER_URL = env('REDIS_URL', default='redis://localhost:6379/0')"
|
||||
new_celery1 = "CELERY_BROKER_URL = env('REDIS_URL', default='memory://')"
|
||||
old_celery2 = "CELERY_RESULT_BACKEND = env('REDIS_URL', default='redis://localhost:6379/0')"
|
||||
new_celery2 = "CELERY_RESULT_BACKEND = env('REDIS_URL', default='cache+memory://')"
|
||||
content = content.replace(old_celery1, new_celery1)
|
||||
content = content.replace(old_celery2, new_celery2)
|
||||
|
||||
with open('config/settings.py', 'w') as f:
|
||||
f.write(content)
|
||||
Reference in New Issue
Block a user