|
130 | 130 | ASGI_APPLICATION = 'openwisp.asgi.application' |
131 | 131 |
|
132 | 132 | REDIS_HOST = os.environ['REDIS_HOST'] |
133 | | -CELERY_BROKER_URL = f'redis://{REDIS_HOST}:6379/1' |
| 133 | +REDIS_PORT = os.environ.get('REDIS_PORT', 6379) |
| 134 | +REDIS_PASS = os.environ.get('REDIS_PASS') |
| 135 | + |
| 136 | +if not REDIS_PASS: |
| 137 | + CHANNEL_REDIS_HOST = f'redis://{REDIS_HOST}:{REDIS_PORT}/1' |
| 138 | +else: |
| 139 | + CHANNEL_REDIS_HOST = f'redis://:{REDIS_PASS}@{REDIS_HOST}:{REDIS_PORT}/1' |
| 140 | + |
| 141 | +if not REDIS_PASS: |
| 142 | + CELERY_BROKER_URL = f'redis://{REDIS_HOST}:{REDIS_PORT}/2' |
| 143 | +else: |
| 144 | + CELERY_BROKER_URL = f'redis://:{REDIS_PASS}@{REDIS_HOST}:{REDIS_PORT}/2' |
134 | 145 | CELERY_TASK_ACKS_LATE = True |
135 | 146 | CELERY_WORKER_PREFETCH_MULTIPLIER = 1 |
136 | 147 | CELERY_BROKER_TRANSPORT_OPTIONS = {'max_retries': 10} |
137 | 148 |
|
138 | 149 | # Database |
139 | 150 | # https://docs.djangoproject.com/en/1.9/ref/settings/#databases |
140 | 151 |
|
141 | | - |
142 | 152 | DB_OPTIONS = { |
143 | 153 | 'sslmode': os.environ['DB_SSLMODE'], |
144 | 154 | 'sslkey': os.environ['DB_SSLKEY'], |
|
170 | 180 |
|
171 | 181 | # Channels(Websocket) |
172 | 182 | # https://channels.readthedocs.io/en/latest/topics/channel_layers.html#configuration |
173 | | - |
174 | 183 | CHANNEL_LAYERS = { |
175 | 184 | 'default': { |
176 | 185 | 'BACKEND': 'channels_redis.core.RedisChannelLayer', |
177 | | - 'CONFIG': {'hosts': [(REDIS_HOST, 6379)]}, |
| 186 | + 'CONFIG': {'hosts': [CHANNEL_REDIS_HOST]}, |
178 | 187 | }, |
179 | 188 | } |
180 | 189 |
|
|
184 | 193 | CACHES = { |
185 | 194 | 'default': { |
186 | 195 | 'BACKEND': 'django_redis.cache.RedisCache', |
187 | | - 'LOCATION': f'redis://{REDIS_HOST}:6379/1', |
| 196 | + 'LOCATION': f'redis://{REDIS_HOST}:{REDIS_PORT}/0', |
188 | 197 | 'OPTIONS': { |
189 | 198 | 'CLIENT_CLASS': 'django_redis.client.DefaultClient', |
190 | 199 | }, |
191 | 200 | } |
192 | 201 | } |
193 | 202 |
|
| 203 | +if REDIS_PASS: |
| 204 | + CACHES['default']['OPTIONS']['PASSWORD'] = os.environ['REDIS_PASS'] |
| 205 | + |
194 | 206 | # Leaflet Configurations |
195 | 207 | # https://django-leaflet.readthedocs.io/en/latest/templates.html#configuration |
196 | 208 |
|
|
0 commit comments