Improved docker related files and added redis server for django channels

This commit is contained in:
Keannu Christian Bernasol 2023-09-12 19:26:37 +08:00
parent 8d88424159
commit 7053f1d487
7 changed files with 333 additions and 198 deletions

View file

@ -21,7 +21,6 @@ load_dotenv() # loads the configs from .env
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
@ -161,7 +160,6 @@ REST_FRAMEWORK = {
WSGI_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
@ -262,3 +260,12 @@ LEAFLET_CONFIG = {
'SCALE': 'both',
'TILES': 'https://openstreetmap.keannu1.duckdns.org/tile/{z}/{x}/{y}.png'
}
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("127.0.0.1", 6379)],
},
},
}

15
stude/wait_for_redis.py Normal file
View file

@ -0,0 +1,15 @@
import time
import os
import redis
REDIS_HOST = os.getenv('REDIS_HOST', 'localhost')
REDIS_PORT = os.getenv('REDIS_PORT', 6379)
if __name__ == '__main__':
while True:
try:
redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
print('Redis is up!')
break
except redis.ConnectionError:
time.sleep(0.1)